14 lines
379 B
TypeScript
14 lines
379 B
TypeScript
import bcrypt from "bcryptjs";
|
|
|
|
const SALT_ROUNDS = 10;
|
|
|
|
export async function hashPassword(password: string): Promise<string> { // hashes and salts password
|
|
return bcrypt.hash(password, SALT_ROUNDS)
|
|
}
|
|
|
|
export async function verifyPassword( // compares password to hash
|
|
password: string,
|
|
hash: string
|
|
): Promise<boolean> {
|
|
return bcrypt.compare(password, hash);
|
|
} |