UNPKG

get-express-starter

Version:

Get production ready express boilerplate with a single command

22 lines (19 loc) 652 B
import * as bcrypt from 'bcryptjs'; /** * Hash a plain text password * @param password The password to hash * @returns The hashed password */ export const hashPassword = async (password: string): Promise<string> => { const salt = await bcrypt.genSalt(10); return bcrypt.hash(password, salt); }; /** * Compare a plain text password with a hashed password * @param password The plain text password * @param hashedPassword The hashed password from the database * @returns Whether the passwords match */ export const comparePassword = async (password: string, hash: string): Promise<boolean> => { return bcrypt.compare(password, hash); };