Rust实现字符串MD5加密


本文将使用Rust语言实现字符串的MD5加密;

首先,在Cargo.toml文件中添加依赖:

[dependencies]
rust-crypto = "0.2.36"

源码如下:


use crypto::md5::Md5;
use crypto::digest::Digest;

fn main(){

    let mut hasher = Md5::new();

    let text = String::from("123456");

    hasher.input_str(&text);
    
    println!("{} => {}",text,hasher.result_str())
    
}

如需转载,请注明出处;本文地址:https://www.perfcode.com/p/rust-implements-string-md5-encryption.html