Skip to content

Commit 17a693f

Browse files
committed
Polyfill Date.now for IE8 comp, fixes #12
1 parent b5e352c commit 17a693f

12 files changed

Lines changed: 73 additions & 68 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules/
22
npm-debug.log
33
.idea/
44
doco/
5+
tests/bench.js

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules/
22
npm-debug.log
33
.idea/
4+
doco/
5+
tests/bench.js
46
*.png

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bcryptjs",
33
"description": "Optimized bcrypt in plain JavaScript with zero dependencies.",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"main": "dist/bcrypt-isaac.js",
66
"license": "New-BSD",
77
"homepage": "http://dcode.io/",

dist/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ option to specify a random fallback for browser environments that do not support
1515
has been compiled with Closure Compiler using advanced optimizations.
1616

1717
The standard version, which is slightly smaller, is recommended if you are already using a Web Crypto API polyfill or
18-
intend to not support anything else.
18+
intend to not support anything else / intend to use a custom random fallback.
1919

2020
### Including ISAAC PRNG as default random fallback
2121

dist/bcrypt-isaac.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@
593593
return utfx;
594594
}();
595595

596+
Date.now = Date.now || function() { return +new Date; };
596597

597598
/**
598599
* @type {number}
@@ -871,7 +872,7 @@
871872
r = lr[off + 1];
872873

873874
l ^= P[0];
874-
for (var i=0; i<=BLOWFISH_NUM_ROUNDS-2;)
875+
for (var i=0, k=BLOWFISH_NUM_ROUNDS-2; i<=k;)
875876
// Feistel substitution on left word
876877
n = S[(l >> 24) & 0xff],
877878
n += S[0x100 | ((l >> 16) & 0xff)],
@@ -896,10 +897,9 @@
896897
* @inner
897898
*/
898899
function _streamtoword(data, offp) {
899-
for (var i = 0, word = 0; i < 4; i++) {
900-
word = (word << 8) | (data[offp] & 0xff);
900+
for (var i = 0, word = 0; i < 4; ++i)
901+
word = (word << 8) | (data[offp] & 0xff),
901902
offp = (offp + 1) % data.length;
902-
}
903903
return { key: word, offp: offp };
904904
}
905905

dist/bcrypt-isaac.min.js

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

dist/bcrypt.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@
589589
return utfx;
590590
}();
591591

592+
Date.now = Date.now || function() { return +new Date; };
592593

593594
/**
594595
* @type {number}
@@ -867,7 +868,7 @@
867868
r = lr[off + 1];
868869

869870
l ^= P[0];
870-
for (var i=0; i<=BLOWFISH_NUM_ROUNDS-2;)
871+
for (var i=0, k=BLOWFISH_NUM_ROUNDS-2; i<=k;)
871872
// Feistel substitution on left word
872873
n = S[(l >> 24) & 0xff],
873874
n += S[0x100 | ((l >> 16) & 0xff)],
@@ -892,10 +893,9 @@
892893
* @inner
893894
*/
894895
function _streamtoword(data, offp) {
895-
for (var i = 0, word = 0; i < 4; i++) {
896-
word = (word << 8) | (data[offp] & 0xff);
896+
for (var i = 0, word = 0; i < 4; ++i)
897+
word = (word << 8) | (data[offp] & 0xff),
897898
offp = (offp + 1) % data.length;
898-
}
899899
return { key: word, offp: offp };
900900
}
901901

dist/bcrypt.min.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "bcryptjs",
33
"description": "Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"author": "Daniel Wirtz <dcode@dcode.io>",
66
"contributors": [
77
"Shane Girish <shaneGirish@gmail.com> (https://github.com/shaneGirish)",

src/bcrypt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@
7171
* @type {?function(number):!Array.<number>}
7272
* @inner
7373
*/
74-
var randomFallback =/*? if (ISAAC) { */ function(len) {
74+
var randomFallback = /*? if (ISAAC) { */function(len) {
7575
for (var a=[], i=0; i<len; ++i)
7676
a[i] = ((0.5 + isaac() * 2.3283064365386963e-10) * 256) | 0;
7777
return a;
78-
};/*? } else { */ null;/*? }*/
78+
};/*? } else { */null;/*? }*/
7979

8080

8181
/**

0 commit comments

Comments
 (0)