Build MerchantFlow onboarding CRM foundation

This commit is contained in:
Oleksandr Prokhorenko
2026-09-24 16:43:22 +03:00
commit 3aa47d825f
78 changed files with 10739 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
import { scryptSync, randomBytes, timingSafeEqual } from 'node:crypto';
export function hashPassword(password: string) {
const salt = randomBytes(16).toString('hex');
return `${salt}:${scryptSync(password, salt, 64).toString('hex')}`;
}
export function verifyPassword(password: string, stored: string) {
const [salt, hash] = stored.split(':');
if (!salt || !hash) return false;
const expected = Buffer.from(hash, 'hex');
const actual = scryptSync(password, salt, 64);
return expected.length === actual.length && timingSafeEqual(actual, expected);
}