init
This commit is contained in:
26
src/bin/debug_password.rs
Normal file
26
src/bin/debug_password.rs
Normal 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),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user