import crypto from 'crypto'; export const encrypt = (password: string) => { const salt = crypto.randomBytes(16).toString('hex'); const hash = crypto.pbkdf2Sync(password, salt, 10000, 512, 'sha512').toString('hex'); return `${salt}:${hash}`; }; export const verify = (test: string, secret: string) => { const [salt, hash] = secret.split(':'); return crypto.pbkdf2Sync(test, salt, 10000, 512, 'sha512').toString('hex') === hash; };