You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-17Lines changed: 28 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ If you are on a stable version of NodeJS, please provide a sufficient code snipp
18
18
19
19
## Version Compatibility
20
20
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._
22
22
23
23
| Node Version | Bcrypt Version |
24
24
| -------------- | ------------------|
@@ -29,6 +29,7 @@ _Please upgrade to atleast v5.0.0 to avoid security issues mentioned below._
29
29
| 8 | >= 1.0.3 < 4.0.0 |
30
30
| 10, 11 | >= 3 |
31
31
| 12 onwards | >= 3.0.6 |
32
+
| 18 onwards | >= 6.0.0 |
32
33
33
34
`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:
34
35
@@ -78,23 +79,23 @@ npm install bcrypt
78
79
79
80
_Pre-built binaries for various NodeJS versions are made available on a best-effort basis._
80
81
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.
82
83
83
84
_There may be an interval between the release of the module and the availabilty of the compiled modules._
84
85
85
86
Currently, we have pre-built binaries that support the following platforms:
86
87
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
90
91
91
92
If you face an error like this:
92
93
93
94
```
94
95
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
95
96
```
96
97
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].
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.
149
150
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:
@@ -239,29 +248,31 @@ We recommend using async API if you use `bcrypt` on a server. Bcrypt hashing is
239
248
*`genSalt(rounds, minor, cb)`
240
249
*`rounds` - [OPTIONAL] - the cost of processing the data. (default - 10)
241
250
*`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.
243
252
*`err` - First parameter to the callback detailing any errors.
244
253
*`salt` - Second parameter to the callback providing the generated salt.
245
254
*`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**).
248
257
*`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.
252
261
*`err` - First parameter to the callback detailing any errors.
253
262
*`encrypted` - Second parameter to the callback providing the encrypted form.
254
263
*`compareSync(data, encrypted)`
255
-
*`data` - [REQUIRED] - data to compare.
264
+
*`data` - [REQUIRED] - data to compare (string or Buffer).
256
265
*`encrypted` - [REQUIRED] - data to be compared to.
257
266
*`compare(data, encrypted, cb)`
258
-
*`data` - [REQUIRED] - data to compare.
267
+
*`data` - [REQUIRED] - data to compare (string or Buffer).
259
268
*`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.
261
270
*`err` - First parameter to the callback detailing any errors.
262
271
*`same` - Second parameter to the callback providing whether the data and encrypted forms match [true | false].
263
272
*`getRounds(encrypted)` - return the number of rounds used to encrypt a given hash
264
273
*`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.
0 commit comments