Skip to content

Commit b69f52c

Browse files
committed
Fix random generator for more than 16 bytes #28
1 parent 088cee7 commit b69f52c

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)