3个版本
0.1.2 | 2023年1月21日 |
---|---|
0.1.1 | 2023年1月21日 |
0.1.0 | 2022年12月22日 |
#1706 在 加密学 中
每月206次下载
用于 2 crates
7KB
99 行
Argon哈希密码
为常见的argon2密码哈希要求提供辅助函数
使用盐创建哈希密码
let (hash, salt) = argon_hash_password::create_hash_and_salt("PlaintextPassword");
然后可以将哈希和盐存储起来
检查哈希
let check = argon_hash_password::check_password_matches("PlaintextPassword", hash, salt);
match check {
true => println!("Correct plaintext password provided"),
false => println!("Incorrect plaintext password provided"),
}
lib.rs
:
使用argon2创建加盐哈希密码的函数
使用盐创建哈希密码
let (hash, salt) = argon_hash_password::create_hash_and_salt("PlaintextPassword").unwrap();
然后可以将哈希和盐存储起来
检查哈希
let check = argon_hash_password::check_password_matches_hash("PlaintextPassword", hash, salt).unwrap();
match check {
true => println!("Correct plaintext password provided"),
false => println!("Incorrect plaintext password provided"),
}
依赖关系
~0.9–1.1MB
~22K SLoC