use std::{fs::File, io, path::Path};
use md5::Md5;
use sha2::{Digest, Sha256, Sha512};
pub fn sha256sum<P>(path: P) -> io::Result<String>
where
P: AsRef<Path>,
{
let mut file = File::open(path)?;
let mut hasher = Sha256::new();
io::copy(&mut file, &mut hasher)?;
Ok(format!("{:x}", hasher.finalize()))
}
pub fn sha512sum<P>(path: P) -> io::Result<String>
where
P: AsRef<Path>,
{
let mut file = File::open(path)?;
let mut hasher = Sha512::new();
io::copy(&mut file, &mut hasher)?;
Ok(format!("{:x}", hasher.finalize()))
}
pub fn md5sum<P>(path: P) -> io::Result<String>
where
P: AsRef<Path>,
{
let mut file = File::open(path)?;
let mut hasher = Md5::new();
io::copy(&mut file, &mut hasher)?;
Ok(format!("{:x}", hasher.finalize()))
}