fn md5_hash_file(path: &Path) -> Option<String> {
    let mut file = fs::File::open(&path).unwrap();
    
    let mut hasher = Sha1::new();
    let mut buffer = [0u8; 1024];
    loop {
        let bytes_read = file.read(&mut buffer).unwrap();
        hasher.input(&buffer[..bytes_read]);
        if bytes_read == 0 {
            break;
        }
    }
    
    let hash_result = hasher.result();
    
    // struggeld with what the heck "hasher.result()" was.
    // turns out its an slice/array of hex bytes.
    // cant use str::from_utf8 to convert it.
    
    let mut s = String::new();
    write!(&mut s, "{:x}", hash_result).expect("Unable to write");
    
    Some(s)
}
// Hash a single path and return as utf8 string.
Hash a single path and return as utf8 string.
Hash a single path and return as utf8 string .
fn md5_hash_file(path: &Path) -> Option<String> {
    let mut file = fs::File::open(&path).unwrap();
    let mut hasher = Sha1::new();
    let mut buffer = [0u8; 1024];
    loop {
        let bytes_read = file.read(&mut buffer).unwrap();
        hasher.input(&buffer[..bytes_read]);
        if bytes_read == 0 {
            break;
        }
    }
    let hash_result = hasher.result();
    // struggeld with what the heck "hasher.result()" was.
    // turns out its an slice/array of hex bytes.
    // cant use str::from_utf8 to convert it.
    let mut s = String::new();
    write!(&mut s, "{:x}", hash_result).expect("Unable to write");
    Some(s)
}
fn md5_hash_file ( path : & Path ) -> Option < String > { let mut file = fs :: File :: open ( & path ) . unwrap ( ) ; let mut hasher = Sha1 :: new ( ) ; let mut buffer = [ 0u8 ; 1024 ] ; loop { let bytes_read = file . read ( & mut buffer ) . unwrap ( ) ; hasher . input ( & buffer [ .. bytes_read ] ) ; if bytes_read == 0 { break ; } } let hash_result = hasher . result ( ) ; // struggeld with what the heck "hasher.result()" was. // turns out its an slice/array of hex bytes. // cant use str::from_utf8 to convert it. let mut s = String :: new ( ) ; write ! ( mut s " " hash_result ) . expect ( " " ) ; Some ( s ) }
Hash a single path and return as utf8 string.
Hash a single path and return as utf8 string .
path
&Path
path
&Path