use sha2::{Digest, Sha256, Sha384, Sha512}; use md5::Md5; use std::fs::File; use std::io; pub fn hash_md5(mut file: File) -> String { let mut hasher = Md5::new(); _ = io::copy(&mut file, &mut hasher); return format!("{:x}", hasher.finalize()); } pub fn hash_sha256(mut file: File) -> String { let mut hasher = Sha256::new(); _ = io::copy(&mut file, &mut hasher); return format!("{:x}", hasher.finalize()); } pub fn hash_sha384(mut file: File) -> String { let mut hasher = Sha384::new(); _ = io::copy(&mut file, &mut hasher); return format!("{:x}", hasher.finalize()); } pub fn hash_sha512(mut file: File) -> String { let mut hasher = Sha512::new(); _ = io::copy(&mut file, &mut hasher); return format!("{:x}", hasher.finalize()); }