1.0.1 • Published 4 years ago

nodeon-crypto v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

nodeON-crypto

A Collection of crypto helper methods.

Build Status

Install

Install the module using NPM:

npm install nodeon-crypto --save

Table of Contents

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

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.