UNPKG

bcrypt-strong-password-hasher

Version:

A secure, zero-dependency password hasher using native Node.js crypto

22 lines (16 loc) 573 B
import assert from 'assert'; import { hashPassword, verifyPassword } from '../src/hasher.js'; (async () => { const password = 'myS3cret!'; const pepper = 'STATIC_PEPPER'; const hashed = await hashPassword(password, { pepper, iterations: 120000 }); console.log('Hashed JSON:', hashed); const valid = await verifyPassword(password, hashed, pepper); const invalid = await verifyPassword('wrongPassword', hashed, pepper); assert.strictEqual(valid, true); assert.strictEqual(invalid, false); console.log('✅ Hash + verify test passed.'); })();