18 lines
498 B
JavaScript
18 lines
498 B
JavaScript
const bcrypt = require('bcrypt');
|
|
const saltRounds = 10;
|
|
const myPlaintextPassword = 's0/\/\P4$$w0rD';
|
|
const someOtherPlaintextPassword = 'not_bacon';
|
|
|
|
function hashPassword() {
|
|
const hash = bcrypt.hashSync(myPlaintextPassword, saltRounds);
|
|
return hash
|
|
}
|
|
|
|
async function checkPassword(h) {
|
|
let t = bcrypt.compareSync(myPlaintextPassword, h); // true
|
|
let b = bcrypt.compareSync(someOtherPlaintextPassword, h); // false
|
|
console.log(t, b)
|
|
}
|
|
|
|
let a = hashPassword()
|
|
checkPassword(a) |