This commit is contained in:
2025-10-23 00:22:43 +08:00
parent 0881d3fbcb
commit d67ab615ce
34 changed files with 9442 additions and 1 deletions

26
src/bin/debug_password.rs Normal file
View File

@ -0,0 +1,26 @@
use bcrypt::{hash, verify, DEFAULT_COST};
fn main() {
let password = "admin123";
// 生成新的哈希
match hash(password, DEFAULT_COST) {
Ok(new_hash) => {
println!("新生成的哈希: {}", new_hash);
// 验证新哈希
match verify(password, &new_hash) {
Ok(is_valid) => println!("新哈希验证结果: {}", is_valid),
Err(e) => println!("新哈希验证错误: {}", e),
}
},
Err(e) => println!("生成哈希错误: {}", e),
}
// 测试数据库中的哈希
let db_hash = "$2b$12$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi";
match verify(password, db_hash) {
Ok(is_valid) => println!("数据库哈希验证结果: {}", is_valid),
Err(e) => println!("数据库哈希验证错误: {}", e),
}
}