2024-03-07 18:30:22 +11:00
|
|
|
import { compareSync as bcryptCompareSync, hashSync as bcryptHashSync } from '@node-rs/bcrypt';
|
2023-12-21 16:02:02 +02:00
|
|
|
import crypto from 'crypto';
|
2023-06-09 18:21:18 +10:00
|
|
|
|
|
|
|
|
import { SALT_ROUNDS } from '../../constants/auth';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated Use the methods built into `bcrypt` instead
|
|
|
|
|
*/
|
|
|
|
|
export const hashSync = (password: string) => {
|
|
|
|
|
return bcryptHashSync(password, SALT_ROUNDS);
|
|
|
|
|
};
|
2023-12-01 05:52:16 +05:30
|
|
|
|
|
|
|
|
export const compareSync = (password: string, hash: string) => {
|
|
|
|
|
return bcryptCompareSync(password, hash);
|
|
|
|
|
};
|
2023-12-21 16:02:02 +02:00
|
|
|
|
|
|
|
|
export const hashString = (input: string) => {
|
|
|
|
|
return crypto.createHash('sha512').update(input).digest('hex');
|
|
|
|
|
};
|