NOTE: Password_hash and salt is a hex string.
Package | |
Description | Hash password and compare with PBKDF2, use sha1, sha256, sha512, etc. |
Node Version | >= 0.11.11 |
npm install pbkdf2
var pbkdf2 = require('pbkdf2');
var p = 'password';
var s = pbkdf2.generateSaltSync(32);
var pwd = pbkdf2.hashSync(p, s, 1, 20, 'sha256');
var bool = pbkdf2.compareSync(pwd, p, s, 1, 20, 'sha256');
hash(password, salt, iterations, keylen, algorithm, callback(error, password_hash))
hashSync(password, salt, iterations, keylen, algorithm)
, return password_hashgenerateSalt(callback(error, salt), saltlen)
generateSaltSync(saltlen)
, return saltcompare(password_hash, password, salt, iterations, keylen, algorithm, callback(error, bool))
compareSync(password_hash, password, salt, iterations, keylen, algorithm)
, return bool