17 lines
435 B
TypeScript
17 lines
435 B
TypeScript
import * as bcrypt from "bcrypt";
|
|
|
|
export async function hashPassword(password: string): Promise<string> {
|
|
const saltRounds = 10;
|
|
const salt = await bcrypt.genSalt(saltRounds);
|
|
const hashedPassword = await bcrypt.hash(password, salt);
|
|
return hashedPassword;
|
|
}
|
|
|
|
export async function checkPassword(
|
|
password: string,
|
|
hash: string
|
|
): Promise<boolean> {
|
|
const match = await bcrypt.compare(password, hash);
|
|
return match;
|
|
}
|