3 ms·
You could use window.crypto.getRandomValues. https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues https://developer.mozilla.org/en-US/d
by johnsonjo 11y ago
You could use window.crypto.getRandomValues. https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues https://developer.mozilla.org/en-US/docs/Web/API/RandomSourc...
Like this possibly:
https://jsfiddle.net/8b6kyjwv/6/ https://jsfiddle.net/8b6kyjwv/6/
I am not sure how random it is to just generate 1 at a time like I did in that fiddle instead of an array at a time.
Here's the article on mdn about the getRandomValues.
https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues https://developer.mozilla.org/en-US/docs/Web/API/RandomSourc...
> The RandomSource.getRandomValues() method lets you get cryptographically random values. The array given as the parameter is filled with random numbers (random in its cryptographic meaning).
> To guarantee enough performance, implementations are not using a truly random number generator, but they are using a pseudo-random number generator seeded with a value with enough entropy. The PRNG used differs from one implementation to the other but is suitable for cryptographic usages. Implementations are also required to use a seed with enough entropy, like a system-level entropy source.