1.0.1 • Published 6 years ago
nodeon-crypto v1.0.1
nodeON-crypto
A Collection of crypto helper methods.
Install
Install the module using NPM:
npm install nodeon-crypto --saveTable of Contents
API
Hash a string using bcrypt
helpers.hash(text, optOpts, done)
- text
stringThe string to hash.- optOpts
Object=Optionally define options.- done
Function()Node.js style callback.
Hashes a string using the bcrypt library.
Bcrypt will only hash strings up to 72 chars long. If the passed string is longer than that the helpers.hash method will fail with a warning. To ignore that behavior set the ignoreLimit option to true:
helpers.hash(longString, {ignoreLimit: true}, function(err, res) {
// Ignoring limit will not create an error
expect(err).to.be.null;
expect(res).to.be.a('string');
});Verify a hashed string match
helpers.hashVerify(hash, text, done)
- hash
stringThe hashed string.- text
stringThe string to test.- done
Function(boolean)Callback with a single argument, boolean.
Tests if the given string matches the provided hash.
Set a salt string
crypto.setSalt(salt)
- salt
stringAny string.
Use it once to set a salt for the crypto functions.
Release History
- v1.0.1, 28 Feb 2020
- Updated all dependencies to latest.
- v1.0.0, 04 May 2016
- Big Bang
License
Copyright Thanasis Polychronakis. Licensed under the MIT license.
