bcrypt nodejs hash password

// Step 1: Import the 'bcrypt' module
const bcrypt = require('bcrypt');

// Step 2: Set the number of salt rounds for hashing
const saltRounds = 10;

// Step 3: Generate a salt using 'genSaltSync' method
const salt = bcrypt.genSaltSync(saltRounds);

// Step 4: Hash the password using 'hashSync' method with the generated salt
const hashedPassword = bcrypt.hashSync('user_password', salt);

// Step 5: Compare a plain text password with a hashed password
const isPasswordMatch = bcrypt.compareSync('user_password', hashedPassword);

// Step 6: Log the hashed password and the result of password comparison
console.log('Hashed Password:', hashedPassword);
console.log('Password Match:', isPasswordMatch);