🛡 scrypt 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.
$ npm install --save credential-plus-scrypt
const credential = require('credential-plus');
credential.install(require('credential-plus-scrypt'));
// Hash and verify with scrypt and default configs
credential.hash('We are all unicorns', {func: 'scrypt'}, (err, hash) => {
console.log(hash);
//=> {"hash":"c2NyeXB0AA8AAAAIAAAAAdZuQumEF/m0V747VleWqvYZKhjOgXgQGtIsgOmLQwwc6KZuU2t1uEkqs9tABwGZyFHdCGkSxzpBLtMgx6UVtKwfcuRGKM2uGu1FvJt8avmU","func":"scrypt"}
credential.verify(hash, 'We are all unicorns', (match) =>{
console.log(match);
//=> true
})
});
Creates a new 'unique' hash from a password.
Type: string
The password to hash.
Type: object
Configurations for the hash function.
Type: number
Default: 0.15
The maximum amount of time in seconds scrypt will spend when computing the derived key.
Type: number
Default: 0
The maximum number of bytes of RAM used when computing the derived encryption key. If not present, will default to 0.
Type: number
Default: 0.5
A double value between 0.0 and 1.0, representing the fraction (normalized percentage value) of the available RAM used when computing the derived key.
Type: function
Called after the hash has been computed.
Type: object
Possible error thrown.
Type: object
The generated hash.
Determines whether or not the user's input matches the stored password.
Type: string
An hash generated from this package.
Type: string
User's input input.
Type: string
Called after the verification process has been computed.
Type: object
Possible error thrown.
Type: boolean
True if the hash computed for the input matches.
- Simone Primarosa - simonepri
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.