Skip to content

Commit 4499f69

Browse files
committed
Little tweaks.
1 parent c3c7c8d commit 4499f69

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

scrypt-async.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* Fast "async" scrypt implementation in JavaScript.
3-
* Copyright (c) 2013-2014 Dmitry Chestnykh | BSD License
3+
* Copyright (c) 2013-2015 Dmitry Chestnykh | BSD License
44
* https://github.com/dchest/scrypt-async-js
55
*/
66

@@ -9,19 +9,16 @@
99
*/
1010

1111
/**
12-
* scrypt(password, salt, logN, r, dkLen, interruptStep, callback, encoding)
12+
* scrypt(password, salt, logN, r, dkLen, interruptStep, callback, [encoding])
13+
* scrypt(password, salt, logN, r, dkLen, callback, [encoding])
1314
*
14-
* Derives a key from password and salt and calls callback
15+
* Async: derives a key from password and salt and calls callback
1516
* with derived key as the only argument.
1617
*
17-
* @param {string|Array.<number>} password Password.
18-
* @param {string|Array.<number>} salt Salt.
19-
* @param {number} logN CPU/memory cost parameter (1 to 31).
20-
* @param {number} r Block size parameter.
21-
* @param {number} dkLen Length of derived key.
22-
* @param {number} interruptStep Steps to split calculation with timeouts (default 1000).
23-
* @param {function(string)} callback Callback function.
24-
* @param {string?} encoding Result encoding ("base64", "hex", or null).
18+
* scrypt(password, salt, logN, r, dkLen, [encoding]) -> returns result
19+
*
20+
* Sync: returns derived key.
21+
*
2522
*/
2623
function scrypt(password, salt, logN, r, dkLen, interruptStep, callback, encoding) {
2724
'use strict';
@@ -333,7 +330,7 @@ function scrypt(password, salt, logN, r, dkLen, interruptStep, callback, encodin
333330
}
334331
if (len % 3 > 0) {
335332
arr[arr.length-1] = '=';
336-
if (len % 3 == 1) arr[arr.length-2] = '=';
333+
if (len % 3 === 1) arr[arr.length-2] = '=';
337334
}
338335
return arr.join('');
339336
}
@@ -355,9 +352,9 @@ function scrypt(password, salt, logN, r, dkLen, interruptStep, callback, encodin
355352
throw new Error('scrypt: parameters are too large');
356353

357354
// Decode strings.
358-
if (typeof password == 'string')
355+
if (typeof password === 'string')
359356
password = stringToUTF8Bytes(password);
360-
if (typeof salt == 'string')
357+
if (typeof salt === 'string')
361358
salt = stringToUTF8Bytes(salt);
362359

363360
if (typeof Int32Array !== 'undefined') {
@@ -429,9 +426,9 @@ function scrypt(password, salt, logN, r, dkLen, interruptStep, callback, encodin
429426

430427
function getResult() {
431428
var result = PBKDF2_HMAC_SHA256_OneIter(password, B, dkLen);
432-
if (encoding == 'base64')
429+
if (encoding === 'base64')
433430
return bytesToBase64(result);
434-
else if (encoding == 'hex')
431+
else if (encoding === 'hex')
435432
return bytesToHex(result);
436433
else
437434
return result;

scrypt-async.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)