pos-be/src/core/helpers/password/bcrypt.helpers.ts

18 lines
422 B
TypeScript

import { compare, hash } from 'bcrypt';
export async function hashPassword(
password: string,
saltRounds: number,
): Promise<string> {
const hashedPassword = await hash(password, 10);
return hashedPassword;
}
export async function validatePassword(
password: string,
hashedPassword: string,
): Promise<boolean> {
const isPasswordValid = await compare(password, hashedPassword);
return isPasswordValid;
}