Skip to content

Commit e937629

Browse files
committed
use buffers in rng
1 parent a40d03a commit e937629

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

rng.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Original code adapted from Robert Kieffer.
22
// details at https://github.com/broofa/node-uuid
3+
4+
35
(function() {
46
var _global = this;
57

68
var mathRNG, whatwgRNG;
79

810
// NOTE: Math.random() does not guarantee "cryptographic quality"
911
mathRNG = function(size) {
10-
var bytes = new Array(size);
12+
var bytes = new Buffer(size);
1113
var r;
1214

1315
for (var i = 0, r; i < size; i++) {
@@ -20,7 +22,7 @@
2022

2123
if (_global.crypto && crypto.getRandomValues) {
2224
whatwgRNG = function(size) {
23-
var bytes = new Uint8Array(size);
25+
var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
2426
crypto.getRandomValues(bytes);
2527
return bytes;
2628
}

0 commit comments

Comments
 (0)