创建一个新项目learn_crate4:
cargo new learn_crate4
修改Cargo.toml文件,在文件最后加上:
rust-crypto = "0.2"
修改main.rs文件:
extern crate crypto;
use crypto::digest::Digest;
use crypto::sha3::Sha3;
fn main() {
let mut hasher = Sha3::sha3_256();
hasher.input_str("hello world");
let result = hasher.result_str();
println!("hash = {}", result);
}
本节全部源代码:
https://github.com/anonymousGiga/learn_rust/tree/master/learn_crate4