interpreter-admin/scripts/create-admin-password.js

22 lines
597 B
JavaScript
Raw Normal View History

2025-06-26 11:24:11 +08:00
const bcrypt = require('bcryptjs');
async function createPasswordHash() {
const password = 'admin123';
const saltRounds = 10;
try {
const hash = await bcrypt.hash(password, saltRounds);
console.log('密码:', password);
console.log('生成的哈希:', hash);
// 验证哈希是否正确
const isValid = await bcrypt.compare(password, hash);
console.log('验证结果:', isValid);
return hash;
} catch (error) {
console.error('生成密码哈希失败:', error);
}
}
createPasswordHash();