Complete the code to import bcrypt in a Node.js file.
const bcrypt = require('[1]');
We use require('bcrypt') to import the bcrypt library for password hashing.
Complete the code to hash a password asynchronously with bcrypt.
const hashedPassword = await bcrypt.[1](password, 10);
Use bcrypt.hash to hash a password asynchronously with a salt rounds value.
Fix the error in the code to compare a plain password with a hashed password.
const isMatch = await bcrypt.[1](plainPassword, hashedPassword);Use bcrypt.compare to check if the plain password matches the hashed password.
Fill both blanks to generate a salt and then hash a password using that salt.
const salt = await bcrypt.[1](12); const hashed = await bcrypt.[2](password, salt);
First generate a salt with genSalt, then hash the password with hash using that salt.
Fill all three blanks to create a function that hashes a password with 10 salt rounds and returns the hashed password.
async function [1](password) { const salt = await bcrypt.[2](10); const hashed = await bcrypt.[3](password, salt); return hashed; }
The function is named hashPassword. It generates a salt with genSalt and hashes the password with hash.