Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_testRandom3() {
this.setState({randombytes_random:null})
let freq = [];
let p = []
for (i = 0; i < 256; ++i) freq[i] = 0;
for (i = 0; i < 5*256; ++i) p.push(Sodium.randombytes_random().then((v) => {
++freq[v & 0xff]
++freq[(v >>> 8) & 0xff]
++freq[(v >>> 16) & 0xff]
++freq[(v >>> 24) & 0xff]
}))
Promise.all(p).then(() => {
var fail = false
for (i = 0; i < 256 && !fail; ++i) if (!freq[i]) fail = true
this.setState({randombytes_random:!fail})
})
}