smaug_lib/util/digest.rs
1use blake2::{Blake2b, Digest};
2use std::path::Path;
3use std::{fs, io};
4
5pub fn file(path: &Path) -> io::Result<String> {
6 let mut file = fs::File::open(path)?;
7 let mut hasher = Blake2b::new();
8 io::copy(&mut file, &mut hasher)?;
9 let hash = hasher.finalize();
10
11 Ok(format!("{:x}", hash))
12}