Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to hash password in node js

npm i bcrypt

const bcrypt = require('bcrypt');
async function hashIt(password){
  const salt = await bcrypt.genSalt(6);
  const hashed = await bcrypt.hash(password, salt);
}
hashIt(password);
// compare the password user entered with hashed pass.
async function compareIt(password){
  const validPassword = await bcrypt.compare(password, hashedPassword);
}
compareIt(password);
 
PREVIOUS NEXT
Tagged: #hash #password #node #js
ADD COMMENT
Topic
Name
5+1 =