bcrypt-nodejs-as-promised

1.0.4 • Public • Published

bcrypt-nodejs-as-promised

This is a modified version of the original bcrypt-as-promised as I was having issues using bcrypt.

Original can be found here bcrypt-as-promised

A promisified version of bcrypt

Install via NPM

npm install bcrypt-nodejs-as-promised

Basic Usage

hashing:

    bcyrpt.hash('my password', 10)
      .then(console.log, console.error)

comparing: (note that an invalid password/hash combo errors as a rejected promise)

    bcyrpt.compare('my password', someHash)
      .then(console.log, console.error)

Note: an invalid password/hash combo errors as a rejected promise

The rejection can be checked against instanceof bcrypt.MISMATCH_ERROR

bcrypt.compare('invalid password', someHash)
  .then(handleValidPassword)
  .catch(bcrypt.MISMATCH_ERROR, handleInvalidPassword)
  .catch(handleOtherErrors);

generating a salt:

    bcyrpt.genSalt(10)
      .then(console.log, console.error)

calculating the rounds used in a salt:

    bcyrpt.getRounds(someHash)
      .then(console.log, console.error)

Package Sidebar

Install

npm i bcrypt-nodejs-as-promised

Weekly Downloads

12

Version

1.0.4

License

MIT

Last publish

Collaborators

  • zodian