Home

Awesome

nodeON-crypto

A Collection of crypto helper methods.

Build Status

Install

Install the module using NPM:

npm install nodeon-crypto --save

<a name='TOC'>Table of Contents</a>

  1. API
    1. Hash a string using bcrypt
    2. Verify a hashed string match
    3. Set a salt string

API

<a name='hash'>Hash a string using bcrypt</a>

helpers.hash(text, optOpts, done)

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');
});

[⬆]

<a name='hashVerify'>Verify a hashed string match</a>

helpers.hashVerify(hash, text, done)

Tests if the given string matches the provided hash.

[⬆]

<a name='setSalt'>Set a salt string</a>

crypto.setSalt(salt)

Use it once to set a salt for the crypto functions.

[⬆]

Release History

License

Copyright Thanasis Polychronakis. Licensed under the MIT license.