25 lines
750 B
JavaScript
25 lines
750 B
JavaScript
const bcrypt = require('bcrypt');
|
|
|
|
async function testBcrypt() {
|
|
const password = 'FlowForge123!';
|
|
|
|
// Generate a new hash
|
|
const salt = await bcrypt.genSalt(10);
|
|
const hash = await bcrypt.hash(password, salt);
|
|
|
|
console.log('Generated hash:', hash);
|
|
console.log('Hash length:', hash.length);
|
|
|
|
// Test the hash we're using in the database
|
|
const dbHash = '$2b$10$3euPcmQFCiblsZeEu5s7p.9wVdLajnYhAbcjkru4KkUGBIm3WVYjK';
|
|
|
|
// Compare the password with both hashes
|
|
const isValidNew = await bcrypt.compare(password, hash);
|
|
const isValidDB = await bcrypt.compare(password, dbHash);
|
|
|
|
console.log('Is valid with new hash:', isValidNew);
|
|
console.log('Is valid with DB hash:', isValidDB);
|
|
}
|
|
|
|
testBcrypt().catch(console.error);
|