https://github.com/beliven-it/fastify-bcrypt
A Bcrypt hash generator & checker
https://github.com/beliven-it/fastify-bcrypt
auth bcrypt checker fastify generator hash js nodejs password
Last synced: 8 months ago
JSON representation
A Bcrypt hash generator & checker
- Host: GitHub
- URL: https://github.com/beliven-it/fastify-bcrypt
- Owner: beliven-it
- License: mit
- Created: 2020-06-11T15:05:14.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-23T21:25:55.000Z (over 1 year ago)
- Last Synced: 2024-04-24T02:39:49.027Z (over 1 year ago)
- Topics: auth, bcrypt, checker, fastify, generator, hash, js, nodejs, password
- Language: JavaScript
- Size: 675 KB
- Stars: 10
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastify-bcrypt
A Bcrypt hash generator & checker
https://it.wikipedia.org/wiki/Bcrypt
[](https://github.com/beliven-it/fastify-bcrypt/actions/workflows/.node.js.yml)
## Install
```bash
$ npm i --save fastify-bcrypt
```
## Usage
```js
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
| Name | Description |
|--------------------|-----------------------------------------------------------------------------|
| `saltWorkFactor` | The salt work factor for the `bcrypt` algorithm. The default value is `10`. |
## Methods
| Name | Description |
|---------------------------------|--------------------------------------------|
| `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
| Name | Description |
|---------------------------------------|--------------------------------------|
| `bcryptHash (claim) [async]` | See `hash`. |
| `bcryptCompare (claim, hash) [async]` | See `compare`. |
## Test
```bash
$ npm test
```
## Acknowledgements
This project is kindly sponsored by:
[](https://www.beliven.com)
## License
Licensed under [MIT](./LICENSE)