//First install required package: npm i bcrypt //import bcrypt import * as bcrypt from 'bcrypt'; //hashing the password using the hash function const recievedPassword = 'password'; const hashedPassword = await bcrypt.hash(recievedPassword, await bcrypt.genSalt()); //To compare/check a password, use the compare function: const isMatch = await bcrypt.compare(recievedPassword, hashedPassword); console.log('passwords: ', isMatch);