https://github.com/charmander/bcrypt-small
Threaded bcrypt bindings for Node.js
https://github.com/charmander/bcrypt-small
bcrypt nodejs password-hash
Last synced: 5 months ago
JSON representation
Threaded bcrypt bindings for Node.js
- Host: GitHub
- URL: https://github.com/charmander/bcrypt-small
- Owner: charmander
- License: isc
- Created: 2015-11-04T04:21:32.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-12-14T23:42:36.000Z (over 1 year ago)
- Last Synced: 2025-09-08T16:54:34.887Z (10 months ago)
- Topics: bcrypt, nodejs, password-hash
- Language: C
- Homepage: https://www.npmjs.com/package/bcrypt-small
- Size: 74.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bcrypt-small
bcrypt-small provides functions to asynchronously create and verify password
hashes.
Passwords are encoded as UTF-8, cannot contain null bytes, and must be
no longer than 72 bytes; an error is produced if these conditions are not met.
## Example
```javascript
import * as bcrypt from 'bcrypt-small';
const hash = await bcrypt.hash('password', 12);
await bcrypt.compare('password', hash)
// true
await bcrypt.compare('not password', hash)
// false
bcrypt.getRounds(hash)
// 12
```
## API
### bcrypt.hash(password, logRounds)
Hashes a password using 2\*\*`logRounds` rounds, returning a promise. The hash
is a 60-character string. `logRounds` should be at least 4 and at most 31. Aim
for 0.1 seconds per hash or more.
### bcrypt.compare(password, expectedHash)
Compares a password to a hash, returning a promise that resolves to `true` if
the password matches the hash and `false` if it does not.
### bcrypt.getRounds(hash)
Returns the number of rounds used to produce the given hash.