credential-plus-pbkdf2
🛡 pbkdf2 plugin for credential-plus
This package is thought to be used in conjunction with credential-plus
If you find a security flaw in this code, please report it.
Install
$ npm install --save credential-plus-pbkdf2
Usage
const credential = require('credential-plus');
credential.install(require('credential-plus-pbkdf2'));
credential.hash('We are all unicorns', {func: 'pbkdf2'}, (err, hash) => {
console.log(hash);
credential.verify(hash, 'We are all unicorns', (match) =>{
console.log(match);
})
});
credential.hash('We are all unicorns', {func: 'pbkdf2', digest: 'sha1', iterations: 15000}, (err, hash) => {
console.log(hash);
credential.verify(hash, 'We are all unicorns', (match) =>{
console.log(match);
})
});
API
hash(password, options, callback)
Creates a new 'unique' hash from a password.
password
Type: string
The password to hash.
options
Type: object
Configurations for the hash function.
iterations
Type: number
Default: 10000
The number of pbkdf2
iterations.
The number of iterations recommended to ensure data safety changes every year as
technology improves.
keylen
Type: number
Default: 128
The length of the generated keys.
digest
Type: string
Default: 'sha512'
The digest algorithm. Available options are: 'sha1'
, 'sha256'
, 'sha512'
.
callback(err, hash)
Type: function
Called after the hash has been computed.
err
Type: object
Possible error thrown.
hash
Type: object
The generated hash.
verify(hash, input, callback)
Determines whether or not the user's input matches the stored password.
hash
Type: string
An hash generated from this package.
input
Type: string
User's input input.
callback(err, valid)
Type: string
Called after the verification process has been computed.
err
Type: object
Possible error thrown.
valid
Type: boolean
True if the hash computed for the input matches.
Authors
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE file for details.