Password Encryption

一个安全的密码哈希 Rust 库,使用 industry-standard 的 Argon2 算法来保护用户密码。
特性
- 使用 Argon2 算法,这是一种内存硬化的密码哈希函数,被选为 Password Hashing Competition 的获胜者
- 自动生成加密安全的盐值
- 提供简单易用的 API 接口
- 支持密码哈希和验证功能
- 具有良好的错误处理机制
依赖
安装
在你的 Cargo.toml 文件中添加以下内容:
[dependencies]
passwordEncryption = "0.1.3"
使用方法
use passwordEncryption::{PasswordHasher, Argon2Impl};
fn main() -> Result<(), Box<dyn std::error::Error>> {
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 文档
有关详细信息,请参阅 API documentation.
许可证
本项目采用 MIT 许可证。详情请见 LICENSE 文件。