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
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+ compilant implementation.
108
+
109
+
Async methods that accept a callback, return a `Promise` when callback is not specified if Promise support is available.
@@ -151,7 +170,7 @@ If you are using bcrypt on a simple script, using the sync mode is perfectly fin
151
170
*`rounds` - [OPTIONAL] - the cost of processing the data. (default - 10)
152
171
*`genSalt(rounds, cb)`
153
172
*`rounds` - [OPTIONAL] - the cost of processing the data. (default - 10)
154
-
*`cb` - [REQUIRED] - a callback to be fired once the salt has been generated. uses eio making it asynchronous.
173
+
*`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.
155
174
*`err` - First parameter to the callback detailing any errors.
156
175
*`salt` - Second parameter to the callback providing the generated salt.
157
176
*`hashSync(data, salt)`
@@ -160,7 +179,7 @@ If you are using bcrypt on a simple script, using the sync mode is perfectly fin
160
179
*`hash(data, salt, cb)`
161
180
*`data` - [REQUIRED] - the data to be encrypted.
162
181
*`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**).
163
-
*`cb` - [REQUIRED] - a callback to be fired once the data has been encrypted. uses eio making it asynchronous.
182
+
*`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.
164
183
*`err` - First parameter to the callback detailing any errors.
165
184
*`encrypted` - Second parameter to the callback providing the encrypted form.
166
185
*`compareSync(data, encrypted)`
@@ -169,7 +188,7 @@ If you are using bcrypt on a simple script, using the sync mode is perfectly fin
169
188
*`compare(data, encrypted, cb)`
170
189
*`data` - [REQUIRED] - data to compare.
171
190
*`encrypted` - [REQUIRED] - data to be compared to.
172
-
*`cb` - [REQUIRED] - a callback to be fired once the data has been compared. uses eio making it asynchronous.
191
+
*`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.
173
192
*`err` - First parameter to the callback detailing any errors.
174
193
*`same` - Second parameter to the callback providing whether the data and encrypted forms match [true | false].
175
194
*`getRounds(encrypted)` - return the number of rounds used to encrypt a given hash
0 commit comments