Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 367x 1x 95x 2x 66x | import bcrypt from "bcrypt";
/**
* Synchronously hashes given password using bcrypt algorithm
*
* @param password Password string to be hashed
* @returns {string} Hashed + salted
*/
export function saltedHash(password: string): string {
return bcrypt.hashSync(password, 10);
}
/**
* Synchronously compares password to hash
*
* @param password Password to be compared with given hash
* @param saltedHash Hash to be compared with password
* @returns {boolean} If password matches hash
*/
export function compareSaltedHash(password: string, saltedHash: string): boolean {
return bcrypt.compareSync(password, saltedHash);
}
|