Skip to content

Commit 86c2b66

Browse files
authored
Merge pull request #1200 from kelektiv/update-readme
Update README
2 parents 57eeffb + 366f2ce commit 86c2b66

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

README.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you are on a stable version of NodeJS, please provide a sufficient code snipp
1818

1919
## Version Compatibility
2020

21-
_Please upgrade to atleast v5.0.0 to avoid security issues mentioned below._
21+
_Please upgrade to at least v5.0.0 to avoid security issues mentioned below._
2222

2323
| Node Version | Bcrypt Version |
2424
| -------------- | ------------------|
@@ -29,6 +29,7 @@ _Please upgrade to atleast v5.0.0 to avoid security issues mentioned below._
2929
| 8 | >= 1.0.3 < 4.0.0 |
3030
| 10, 11 | >= 3 |
3131
| 12 onwards | >= 3.0.6 |
32+
| 18 onwards | >= 6.0.0 |
3233

3334
`node-gyp` only works with stable/released versions of node. Since the `bcrypt` module uses `node-gyp` to build and install, you'll need a stable version of node to use bcrypt. If you do not, you'll likely see an error that starts with:
3435

@@ -78,23 +79,23 @@ npm install bcrypt
7879

7980
_Pre-built binaries for various NodeJS versions are made available on a best-effort basis._
8081

81-
Only the current stable and supported LTS releases are actively tested against.
82+
Only the current stable and supported LTS releases (Node 18+) are actively tested against.
8283

8384
_There may be an interval between the release of the module and the availabilty of the compiled modules._
8485

8586
Currently, we have pre-built binaries that support the following platforms:
8687

87-
1. Windows x32 and x64
88-
2. Linux x64 (GlibC and musl)
89-
3. macOS
88+
1. Windows x64 and arm64
89+
2. Linux x64 and arm64 (GlibC and musl)
90+
3. macOS x64 and arm64
9091

9192
If you face an error like this:
9293

9394
```
9495
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-linux-x64.tar.gz
9596
```
9697

97-
make sure you have the appropriate dependencies installed and configured for your platform. You can find installation instructions for the dependencies for some common platforms [in this page][depsinstall].
98+
Make sure you have the appropriate dependencies installed and configured for your platform. You can find installation instructions for the dependencies for some common platforms [in this page][depsinstall].
9899

99100
## Usage
100101

@@ -145,9 +146,17 @@ bcrypt.compare(someOtherPlaintextPassword, hash, function(err, result) {
145146

146147
### with promises
147148

148-
bcrypt uses whatever `Promise` implementation is available in `global.Promise`. NodeJS >= 0.12 has a native `Promise` implementation built in. However, this should work in any Promises/A+ compliant implementation.
149+
bcrypt uses whatever `Promise` implementation is available in `global.Promise`. NodeJS has a native `Promise` implementation built in. However, this should work in any Promises/A+ compliant implementation.
149150

150-
Async methods that accept a callback, return a `Promise` when callback is not specified if Promise support is available.
151+
Async methods that accept a callback, return a `Promise` when the callback is not specified if Promise support is available.
152+
153+
The Promise implementation can be customized using the `bcrypt.promises.use()` method:
154+
155+
```javascript
156+
// Example: Using a custom Promise implementation
157+
const bluebird = require('bluebird');
158+
bcrypt.promises.use(bluebird);
159+
```
151160

152161
```javascript
153162
bcrypt.hash(myPlaintextPassword, saltRounds).then(function(hash) {
@@ -239,29 +248,31 @@ We recommend using async API if you use `bcrypt` on a server. Bcrypt hashing is
239248
* `genSalt(rounds, minor, cb)`
240249
* `rounds` - [OPTIONAL] - the cost of processing the data. (default - 10)
241250
* `minor` - [OPTIONAL] - minor version of bcrypt to use. (default - b)
242-
* `cb` - [OPTIONAL] - a callback to be fired once the salt has been generated. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available.
251+
* `cb` - [OPTIONAL] - a callback to be fired once the salt has been generated. If `cb` is not specified, a `Promise` is returned if Promise support is available.
243252
* `err` - First parameter to the callback detailing any errors.
244253
* `salt` - Second parameter to the callback providing the generated salt.
245254
* `hashSync(data, salt)`
246-
* `data` - [REQUIRED] - the data to be encrypted.
247-
* `salt` - [REQUIRED] - the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**).
255+
* `data` - [REQUIRED] - the data to be encrypted (string or Buffer).
256+
* `salt` - [REQUIRED] - the salt to be used to hash the password. If specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**).
248257
* `hash(data, salt, cb)`
249-
* `data` - [REQUIRED] - the data to be encrypted.
250-
* `salt` - [REQUIRED] - the salt to be used to hash the password. if specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**).
251-
* `cb` - [OPTIONAL] - a callback to be fired once the data has been encrypted. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available.
258+
* `data` - [REQUIRED] - the data to be encrypted (string or Buffer).
259+
* `salt` - [REQUIRED] - the salt to be used to hash the password. If specified as a number then a salt will be generated with the specified number of rounds and used (see example under **Usage**).
260+
* `cb` - [OPTIONAL] - a callback to be fired once the data has been encrypted. If `cb` is not specified, a `Promise` is returned if Promise support is available.
252261
* `err` - First parameter to the callback detailing any errors.
253262
* `encrypted` - Second parameter to the callback providing the encrypted form.
254263
* `compareSync(data, encrypted)`
255-
* `data` - [REQUIRED] - data to compare.
264+
* `data` - [REQUIRED] - data to compare (string or Buffer).
256265
* `encrypted` - [REQUIRED] - data to be compared to.
257266
* `compare(data, encrypted, cb)`
258-
* `data` - [REQUIRED] - data to compare.
267+
* `data` - [REQUIRED] - data to compare (string or Buffer).
259268
* `encrypted` - [REQUIRED] - data to be compared to.
260-
* `cb` - [OPTIONAL] - a callback to be fired once the data has been compared. uses eio making it asynchronous. If `cb` is not specified, a `Promise` is returned if Promise support is available.
269+
* `cb` - [OPTIONAL] - a callback to be fired once the data has been compared. If `cb` is not specified, a `Promise` is returned if Promise support is available.
261270
* `err` - First parameter to the callback detailing any errors.
262271
* `same` - Second parameter to the callback providing whether the data and encrypted forms match [true | false].
263272
* `getRounds(encrypted)` - return the number of rounds used to encrypt a given hash
264273
* `encrypted` - [REQUIRED] - hash from which the number of rounds used should be extracted.
274+
* `promises.use(promiseImplementation)` - change the Promise implementation that bcrypt uses
275+
* `promiseImplementation` - [REQUIRED] - a Promises/A+ compatible implementation to be used.
265276

266277
## A Note on Rounds
267278

0 commit comments

Comments
 (0)