Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 1.01 KB

README.md

File metadata and controls

30 lines (22 loc) · 1.01 KB

Build Status Coverage Status

PBKDF2

This library generates a formatted hash that you can store in your database as a single value.

The format is ALGORITHM:ITTERATIONS:SALT:DERIVED_KEY.

Usage

var PBKDF2 = require('painless-pbkdf2')

Create a password hash

var password = new PBKDF2()
password.create('test123', function(err, hash) {
  // hash: (sha256:64000:VImSI/1MUSFHuQzrbelyaKnjDcp7LoZwZRZmc8ErLq4=:708eb4b660fdb56b911abbdc26faae0aa195dbc84e46da23d48ae7630ef25808)
})

Validate a hash

var hash = 'sha256:64000:VImSI/1MUSFHuQzrbelyaKnjDcp7LoZwZRZmc8ErLq4=:708eb4b660fdb56b911abbdc26faae0aa195dbc84e46da23d48ae7630ef25808'
password = new PBKDF2(hash)

password.validate('test123', function (err, valid) {
  // valid: (true | false)
})