Password Hashing with bcrypt
Hashing and verifying passwords in Node.js.
Use https://www.npmjs.com/package/bcrypt
Hashing
javascript
import * as bcrypt from 'bcrypt';
const saltOrRounds = 10;
const salt = await bcrypt.genSalt(saltOrRounds); // default rounds is 10
const hash = await bcrypt.hash(password, salt);Comparing
javascript
const isMatch = await bcrypt.compare(password, hash);