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
+8-2
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ This module will change and do the following things for you:
7
7
* Input values (passwords, usually) are expected in utf-8.
8
8
* Output/hash values are base64-encoded, and can be stored directly in your data store of choice.
9
9
* Scrypt parameters are set to `scrypt.params(0.1)`, this can be overridden on a per-hash basis (see API documentation below).
10
-
* Scrypt errors, which are not proper Error types in the original library, are caught and rethrown as one of three correctly-inheriting Error types (see API documentation below). This means you can handle them like any other kind of Error.
10
+
* Scrypt errors, which are now proper Error types in the original library but still not easily distinguishable, are caught and rethrown as one of three correctly-inheriting Error types (see API documentation below). This means you can handle them like any other kind of Error.
Due to changes in the underlying `scrypt` library, there has been a minor indirect change in our documented API as well. Specifically, `scrypt.scryptLib.params` is now asynchronous by default, with (poor) support for ES6 Promises. The new documentation can be found [here](https://github.com/barrysteyn/node-scrypt/blob/master/Readme.md#params). Due to its inconsistent behaviour, I recommend manual promisification using [Bluebird](https://www.npmjs.com/package/bluebird) or [`es6-promisify`](https://www.npmjs.com/package/es6-promisify).
93
+
94
+
The other changes in `scrypt` do not affect the `scrypt-for-humans` API, other than introducing support for Node.js 4. If you were not using custom `params`, you can remain using `scrypt-for-humans` like you have done previously.
95
+
90
96
## API
91
97
92
98
### scrypt.hash(input, [options, [callback]])
@@ -95,7 +101,7 @@ Creates a hash.
95
101
96
102
*__input__: The input to hash, usually a password.
97
103
*__options__: *Optional.* Custom options.
98
-
* __options.params__: Sets the Scrypt parameters to use. Defaults to `scrypt.params(0.1)`. If you want to change these, you'll probably need scrypt.scryptLib (documented below).
104
+
* __options.params__: Sets the Scrypt parameters to use. Defaults to `scrypt.params(0.1)`. If you want to change these, you'll probably need `scrypt.scryptLib` (documented below).
99
105
*__callback__: *Optional.* A nodeback to call upon completion. If omitted, the function will return a Promise.
100
106
101
107
If this is successful, the hash is returned as either the resolved Promise value or the second callback parameter, depending on the API you use.
# This wrapper function is to ensure that we only calculate the parameters once, but can still skip waiting for that if custom parameters were passed in anyway.
32
+
if params?
33
+
return params
34
+
else
35
+
return defaultParameters
36
+
37
+
normalizePassword= (password) ->
38
+
ifBuffer.isBuffer(password)
39
+
return password
40
+
else
41
+
returnnewBuffer(password)
18
42
19
43
scryptHandler= (resolve, reject) ->
20
-
#This is ridiculous, but `scrypt` doesn't have proper error-handling facilities...
44
+
#Well, `scrypt` now returns real Error objects. Except now they don't have error codes anymore...
# We will still manually promisify, because the behaviour of `scrypt` is not predictable. It may either synchronously throw an error or return a Promise, depending on available ECMAScript features...
0 commit comments