|
@ -14,7 +14,7 @@ Random.getRandomBuffer = function(size) { |
|
|
Random.getRandomBufferNode = function(size) { |
|
|
Random.getRandomBufferNode = function(size) { |
|
|
var crypto = require('crypto'); |
|
|
var crypto = require('crypto'); |
|
|
return crypto.randomBytes(size); |
|
|
return crypto.randomBytes(size); |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
Random.getRandomBufferBrowser = function(size) { |
|
|
Random.getRandomBufferBrowser = function(size) { |
|
|
if (!window.crypto && !window.msCrypto) |
|
|
if (!window.crypto && !window.msCrypto) |
|
@ -38,11 +38,12 @@ Random.getRandomBufferBrowser = function(size) { |
|
|
Random.getPseudoRandomBuffer = function(size) { |
|
|
Random.getPseudoRandomBuffer = function(size) { |
|
|
var b32 = 0x100000000; |
|
|
var b32 = 0x100000000; |
|
|
var b = new Buffer(size); |
|
|
var b = new Buffer(size); |
|
|
|
|
|
var r; |
|
|
|
|
|
|
|
|
for (var i = 0; i <= size; i++) { |
|
|
for (var i = 0; i <= size; i++) { |
|
|
var j = Math.floor(i / 4); |
|
|
var j = Math.floor(i / 4); |
|
|
var k = i - j * 4; |
|
|
var k = i - j * 4; |
|
|
if (k == 0) { |
|
|
if (k === 0) { |
|
|
r = Math.random() * b32; |
|
|
r = Math.random() * b32; |
|
|
b[i] = r & 0xff; |
|
|
b[i] = r & 0xff; |
|
|
} else { |
|
|
} else { |
|
|