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;
};