mirror of
https://github.com/gchq/CyberChef
synced 2025-01-06 09:38:46 +00:00
Merge branch 'large-prng' of https://github.com/mikecat/CyberChef
This commit is contained in:
commit
a4e20c7059
1 changed files with 6 additions and 2 deletions
|
@ -52,8 +52,12 @@ class PseudoRandomNumberGenerator extends Operation {
|
||||||
let bytes;
|
let bytes;
|
||||||
|
|
||||||
if (isWorkerEnvironment() && self.crypto) {
|
if (isWorkerEnvironment() && self.crypto) {
|
||||||
bytes = self.crypto.getRandomValues(new Uint8Array(numBytes));
|
bytes = new ArrayBuffer(numBytes);
|
||||||
bytes = Utils.arrayBufferToStr(bytes.buffer);
|
const CHUNK_SIZE = 65536;
|
||||||
|
for (let i = 0; i < numBytes; i += CHUNK_SIZE) {
|
||||||
|
self.crypto.getRandomValues(new Uint8Array(bytes, i, Math.min(numBytes - i, CHUNK_SIZE)));
|
||||||
|
}
|
||||||
|
bytes = Utils.arrayBufferToStr(bytes);
|
||||||
} else {
|
} else {
|
||||||
bytes = forge.random.getBytesSync(numBytes);
|
bytes = forge.random.getBytesSync(numBytes);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue