Skip to content

Commit 5c27b4f

Browse files
committed
Merge pull request #29 from tonistiigi/fix-random
Fix random generator for more than 16 bytes #28
2 parents bcbf877 + b69f52c commit 5c27b4f

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

rng.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,9 @@
1919
}
2020

2121
if (_global.crypto && crypto.getRandomValues) {
22-
var _rnds = new Uint32Array(4);
2322
whatwgRNG = function(size) {
24-
var bytes = new Array(size);
25-
crypto.getRandomValues(_rnds);
26-
27-
for (var c = 0 ; c < size; c++) {
28-
bytes[c] = _rnds[c >> 2] >>> ((c & 0x03) * 8) & 0xff;
29-
}
23+
var bytes = new Uint8Array(size);
24+
crypto.getRandomValues(bytes);
3025
return bytes;
3126
}
3227
}

0 commit comments

Comments
 (0)