nodeon-crypto
v1.0.1
Published
A Collection of crypto helper methods.
Downloads
3
Readme
nodeON-crypto
A Collection of crypto helper methods.
Install
Install the module using NPM:
npm install nodeon-crypto --save
Table of Contents
API
Hash a string using bcrypt
helpers.hash(text, optOpts, done)
- text
string
The 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
string
The hashed string.- text
string
The 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
string
Any 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.