Complete the code to import bcrypt in an Express app.
const bcrypt = require('[1]');
We import the bcrypt library by requiring 'bcrypt'. This allows us to use bcrypt functions for password hashing.
Complete the code to hash a password asynchronously using bcrypt.
const hashedPassword = await bcrypt.[1](password, 10);
The hash function creates a hashed version of the password using a salt rounds value (10 here).
Fix the error in the code to compare a plain password with a hashed password.
const isMatch = await bcrypt.[1](password, hashedPassword);The compare function checks 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, genSalt creates a salt with 12 rounds. Then, hash uses that salt to hash the password.
Fill all three blanks to create a function that hashes a password and returns the hashed value.
async function [1](password) { const salt = await bcrypt.[2](10); const hash = await bcrypt.[3](password, salt); return hash; }
This function named hashPassword generates a salt with 10 rounds, hashes the password with that salt, and returns the hashed password.