Node.js & Libuv•Part 3: Streams, Buffers & Core Modules (21 - 35)
The `crypto` module: Secure password hashing.
In Simple Words:
Use crypto.scrypt() or crypto.pbkdf2() with salt and high work factors for password hashing, or modern native algorithms like Argon2 via dedicated bindings.
javascript
const crypto = require('crypto');
function hashPassword(password) {
const salt = crypto.randomBytes(16).toString('hex');
const derivedKey = crypto.scryptSync(password, salt, 64);
return `${salt}:${derivedKey.toString('hex')}`;
}