Node کا built-in crypto module cryptographic functions فراہم کرتا ہے: hashing، encryption، random values، اور HMAC۔ سب سے اہم عملی استعمال — password hashing — کا ایک نہایت اہم اصول ہے: passwords کے لیے کبھی تیز، general-purpose hashes (MD5/SHA-256) استعمال نہ کریں۔
Password hashing: ایک سست، salted algorithm استعمال کریں
{ scrypt, randomBytes, timingSafeEqual } ;
{ promisify } ;
scryptAsync = (scrypt);
() {
salt = ().();
derived = (password, salt, );
;
}
() {
[salt, hash] = stored.();
derived = (password, salt, );
hashBuf = .(hash, );
(hashBuf, derived);
}
