Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Promises A+ version of bcrypt (exposing the `when` API) NOTE - we don't use this version. We use the official one from npm.

License

Notifications You must be signed in to change notification settings

socialtables/bcrypt-as-promised

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bcrypt-as-promised

Build Status

A promisified version of bcrypt

Install via NPM

npm install bcrypt-as-promised

Basic Usage

hashing:

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

comparing:

bcrypt.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:

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

calculating the rounds used in a salt:

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

About

Promises A+ version of bcrypt (exposing the `when` API) NOTE - we don't use this version. We use the official one from npm.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%