A promisified version of bcrypt
npm install bcrypt-as-promised
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)