credential-plus
🛡 Easy password hashing and verification in Node. Protects against brute force, rainbow tables, and timing attacks.
Install
$ npm install --save credential-plus
Plugins
In order to use this package you need at least one plugin. (aka hash function)
You can chose one ore more of those plugins:
If you create your own plugin, please open a PR and add it to this list.
Usage
Lets call X
the plugin package of your choice.
const credential = require('credential-plus');
credential.install(require('credential-plus-X'));
credential.hash('We are all humans', {func: 'X'}, (err, hash) => {
console.log(hash);
credential.verify(hash, 'We are all humans', (match) =>{
console.log(match);
})
credential.verify(hash, 'We are all unicorns', (match) =>{
console.log(match);
})
});
You can find more detailed usage in the usage section of each plugin:
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.
func
Type: string
The name of the plugin (hash function) to use.
This is the only option field required.
Options available are different for each hash function.
See the API section of the plugin you choose for more details:
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.
install(plugin)
Installs an hash function plugin.
plugin
A plugin compatible with this package.
plugins()
Returns the array of the installed plugins (hash functions).
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.