bcrypt
path: courses/express-node/bcrypt.md
- **fileName**: bcrypt
- **Created on**: 2024-07-13 12:31:43
installation
npm i bcrypt
import bcrypt, { compareSync } from "bcrypt";
export const hashPassword = (plainText) => {
const hashResult = bcrypt.hashSync(
plainText,
parseInt(process.env.SALT) // nice ot 10 salt
);
return hashResult;
};
export const comparePassword = (plainText, hash) => {
const match = compareSync(plainText, hash);
return match;
};
-
hashPassword
Function: Hashes a plain text password using bcrypt and a specified number of salt rounds. -
comparePassword
Function: Compares a plain text password with a hashed password to verify if they match.continue:jwt.md
before:passport.md