Cargo.toml
[dependencies]
md5 = "0.7.0"
Code
use std::fs;
fn main() {
let content = fs::read_to_string("main.rs").unwrap();
let hash = md5::compute(content);
println!("md5: {:?}", hash);
}
Run
Use cargo run
get result:
md5: f6c1bbeb1f3a85a44bc550a03f02398e
To verify our code works correctly, we use md5sum
shell command to calculate the md5 value:
$ md5sum main.rs
f6c1bbeb1f3a85a44bc550a03f02398e main.rs
You can see the value is the same as we computed.
Top comments (0)