Initial commit: 宁夏智慧养殖监管平台

This commit is contained in:
shenquanyi
2025-08-25 15:00:46 +08:00
commit ec72c6a8b5
177 changed files with 37263 additions and 0 deletions

31
backend/test_bcrypt.js Normal file
View File

@@ -0,0 +1,31 @@
const bcrypt = require('bcrypt');
async function testBcrypt() {
try {
const password = '123456';
const storedHash = '$2b$10$yTdFpkw5MPU5OprOE7xWJ.arvesmRxKm2MpjwdbzNpEUIR2lq4C9S';
console.log('测试密码:', password);
console.log('存储的哈希:', storedHash);
// 直接使用 bcrypt.compare
const result1 = await bcrypt.compare(password, storedHash);
console.log('bcrypt.compare 结果:', result1);
// 生成新的哈希并测试
const newHash = await bcrypt.hash(password, 10);
console.log('新生成的哈希:', newHash);
const result2 = await bcrypt.compare(password, newHash);
console.log('新哈希验证结果:', result2);
// 测试同步方法
const result3 = bcrypt.compareSync(password, storedHash);
console.log('bcrypt.compareSync 结果:', result3);
} catch (error) {
console.error('测试失败:', error);
}
}
testBcrypt();