Hashifier
Light-weight wrapper to nodejs crypto library for hashing passwords using pbkdf2
Requirements
node 6.
Install
npm install hashifier
API
Each function returns a promise that resolves as specified.
Any errors encountered by nodejs (i.e. passing 0 for iterations) will reject the promise.
hash(plainText, options?)
- hash a given password
- resolves to an object, {hash, salt}
- see options below
compare(plainText, hash, salt, options?)
- compare a previously hashed password
- resolves to a boolean
- see options below
options
- iterations - number of iterations to hash (default 100,000)
- algorithm - algorithm to use for hashing (default sha512)
- encoding - output encoding to use (default hex)
- saltLength - number of bytes to use for the salt (default 128)
- keyLength - length of the key (default 128)
Usage
const hashifier = // options are optional, following is defaultconst options = iterations: 100000 algorithm: 'sha512' encoding: 'hex' saltLength: = 128 keyLength: 128 hashifierhash'my password' options // {salt: string, hash: string}
License
MIT.