xxxxxxxxxx
bcrypt.genSalt(saltRounds, (err, salt) => {
bcrypt.hash(yourPassword, salt, (err, hash) => {
console.log(salt + hash)
});
});
xxxxxxxxxx
const bcrypt = require('bcrypt');
// Plain text password to be hashed
const plainPassword = 'myPassword123';
// Generate a salt
const saltRounds = 10;
const salt = bcrypt.genSaltSync(saltRounds);
// Hash the password using the generated salt
const hashedPassword = bcrypt.hashSync(plainPassword, salt);
console.log('Password:', plainPassword);
console.log('Hashed Password:', hashedPassword);
// Comparing a password with the hashed password
const isPasswordMatch = bcrypt.compareSync(plainPassword, hashedPassword);
console.log('Is Password Match:', isPasswordMatch);
xxxxxxxxxx
const bcrypt = require('bcrypt');
const saltRounds = 10;
const plainPassword = 'myPassword';
bcrypt.hash(plainPassword, saltRounds, function(err, hashedPassword) {
if (err) {
console.error('Error while hashing password:', err);
return;
}
console.log('Hashed password:', hashedPassword);
// Store the hashed password in the database or handle it as needed
});
xxxxxxxxxx
const bcrypt = require('bcryptjs');
const password = 'myPassword';
const saltRounds = 10;
const hashedPassword = bcrypt.hashSync(password, saltRounds);
console.log(hashedPassword);