| Crates.io | passwordEncryption |
| lib.rs | passwordEncryption |
| version | 0.1.3 |
| created_at | 2025-12-03 13:23:50.613169+00 |
| updated_at | 2025-12-04 03:42:54.907099+00 |
| description | 一个安全的密码哈希库,使用 Argon2 算法保护用户密码 |
| homepage | |
| repository | https://github.com/zhuyu12246/passwordEncryption |
| max_upload_size | |
| id | 1964009 |
| size | 20,275 |
一个安全的密码哈希 Rust 库,使用 industry-standard 的 Argon2 算法来保护用户密码。
在你的 Cargo.toml 文件中添加以下内容:
[dependencies]
passwordEncryption = "0.1.3"
use passwordEncryption::{PasswordHasher, Argon2Impl};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 创建一个使用 Argon2 算法的密码哈希器实例
let hasher = PasswordHasher::new(Box::new(Argon2Impl::default()));
let password = "my_secure_password";
// 对密码进行哈希处理
let hashed = hasher.hash_password(password)?;
println!("Original password: {}", password);
println!("Hashed password: {}", hashed);
// 验证正确密码
assert!(hasher.verify_password(password, &hashed)?);
// 验证错误密码
assert!(!hasher.verify_password("wrong_password", &hashed)?);
Ok(())
}
有关详细信息,请参阅 API documentation.
本项目采用 MIT 许可证。详情请见 LICENSE 文件。