Change randomize method from Math.random to Crypto
This commit is contained in:
parent
ade8a9e540
commit
e976d1c5bc
@ -23,9 +23,14 @@ Object.defineProperty(Uint8Array.prototype, 'hex', {
|
||||
|
||||
Uint8Array.prototype.randomize = function() {
|
||||
//secureRandom.nextBytes(this);
|
||||
for(let i = 0; i < this.length; ++i) {
|
||||
this[i] = nextRandomInt(255);
|
||||
if(crypto && 'getRandomValues' in crypto) {
|
||||
crypto.getRandomValues(this);
|
||||
} else {
|
||||
for(let i = 0; i < this.length; ++i) {
|
||||
this[i] = nextRandomInt(255);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user