xxxxxxxxxx
const bcrypt = require('bcryptjs');
const password = 'myPassword';
const saltRounds = 10;
const hashedPassword = bcrypt.hashSync(password, saltRounds);
console.log(hashedPassword);
xxxxxxxxxx
bcrypt.genSalt(saltRounds, (err, salt) => {
bcrypt.hash(yourPassword, salt, (err, hash) => {
console.log(salt + hash)
});
});
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
});