Files
sign/packages/lib/server-only/auth/hash.ts

20 lines
566 B
TypeScript
Raw Normal View History

import { compareSync as bcryptCompareSync, hashSync as bcryptHashSync } from '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);
};
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');
};