2025-07-18 00:08:01 -06:00
|
|
|
use sha2::{Digest, Sha256, Sha384, Sha512};
|
2025-07-18 01:13:11 -06:00
|
|
|
use md5::Md5;
|
2025-07-18 00:08:01 -06:00
|
|
|
use std::fs::File;
|
|
|
|
use std::io;
|
|
|
|
|
2025-07-18 01:13:11 -06:00
|
|
|
pub fn hash_md5(mut file: File) -> String {
|
|
|
|
let mut hasher = Md5::new();
|
|
|
|
_ = io::copy(&mut file, &mut hasher);
|
|
|
|
|
|
|
|
return format!("{:x}", hasher.finalize());
|
|
|
|
}
|
|
|
|
|
2025-07-18 00:08:01 -06:00
|
|
|
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());
|
|
|
|
}
|