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

20 lines
575 B
TypeScript
Raw Normal View History

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);
};
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');
};