Migration

This commit is contained in:
2024-03-21 09:35:29 +01:00
commit ffc6304f6e
8206 changed files with 26300 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
use sha2::{Digest, Sha256};
use std::{fs::File, io};
pub fn file_hash(filename: &str) -> Result<String, std::io::Error> {
let mut file = File::open(filename)?;
let mut hasher = Sha256::new();
io::copy(&mut file, &mut hasher)?;
Ok(format!("{:x}", hasher.finalize()))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let hash = file_hash("Cargo.toml").unwrap();
assert_eq!(
hash,
"02272c4c973d0bf266b571bf596797f46602ae6796d33df4b4057a170483d8f8"
);
}
}