1.0.1 • Published 2 years ago

fastify-bcrypt v1.0.1

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

fastify-bcrypt

A Bcrypt hash generator & checker

https://it.wikipedia.org/wiki/Bcrypt

Node.js CI

Install

$ npm i --save fastify-bcrypt

Usage

fastify.register(require('fastify-bcrypt'), {
  saltWorkFactor: 12
})

fastify.bcrypt.hash('password')
  .then(hash => fastify.bcrypt.compare('password', hash))
  .then(match => console.log(match ? 'Matched!' : 'Not matched!'))
  .catch(err => console.error(err.message))

// Matched!

Options

NameDescription
saltWorkFactorThe salt work factor for the bcrypt algorithm. The default value is 10.

Methods

NameDescription
hash (claim) [async]Generate an hash of given claim.
compare (claim, hash) [async]Compare an hashed claim with hash. NOTE: they're not reversible!

Request

NameDescription
bcryptHash (claim) [async]See hash.
bcryptCompare (claim, hash) [async]See compare.

Test

$ npm test

Acknowledgements

This project is kindly sponsored by:

Beliven

License

Licensed under MIT