You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
337 B
15 lines
337 B
import bcrypt from "bcryptjs";
|
|
|
|
const ROUNDS = 10;
|
|
|
|
export async function hashPassword(plain: string): Promise<string> {
|
|
const salt = await bcrypt.genSalt(ROUNDS);
|
|
return bcrypt.hash(plain, salt);
|
|
}
|
|
|
|
export async function verifyPassword(
|
|
plain: string,
|
|
hash: string,
|
|
): Promise<boolean> {
|
|
return bcrypt.compare(plain, hash);
|
|
}
|
|
|