12 lines
308 B
TypeScript
12 lines
308 B
TypeScript
import bcrypt from 'bcryptjs';
|
|
|
|
export const BCRYPT_ROUNDS = 12;
|
|
|
|
export async function hashPassword(plain: string): Promise<string> {
|
|
return bcrypt.hash(plain, BCRYPT_ROUNDS);
|
|
}
|
|
|
|
export async function verifyPassword(plain: string, hash: string): Promise<boolean> {
|
|
return bcrypt.compare(plain, hash);
|
|
}
|