News for hackers. Stuff that matters.
Re:Creating randomness Without Math.random by galaxyLogic on Sunday July 12, 2020 @11:52PM (#23816990)
It would be great if JavaScript had also a built-in seedable random number generator.
Re:Creating randomness Without Math.random by yesbabyyes on Monday July 13, 2020 @03:00AM (#23817813)
It depends on the implementation, e.g. Node has crypto.getRandomBytes()¹.

If you mean the standard browser implementation, Crypto.getRandomValues()² may be what you're looking for. Note that the browser implementation of this is only a recommendation, so YMMV:

> 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 pseudo-random number generator algorithm (PRNG) may vary across user agents, but is suitable for cryptographic purposes. Implementations are required to use a seed with enough entropy, like a system-level entropy source.

> [...]

> There is no minimum degree of entropy mandated by the Web Cryptography specification. User agents are instead urged to provide the best entropy they can when generating random numbers, using a well-defined, efficient pseudorandom number generator built into the user agent itself, but seeded with values taken from an external source of pseudorandom numbers, such as a platform-specific random number function, the Unix /dev/urandom device, or other source of random or pseudorandom data.

¹ https://nodejs.org/api/crypto.html#crypto_crypto_randombytes...

² https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getR...

Re:Creating randomness Without Math.random by galaxyLogic on Monday July 20, 2020 @12:54PM (#23899639)
From what I can see at https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getR... or https://nodejs.org/api/crypto.html#crypto_crypto_randombytes...

... neither crypto.getRandomBytes() nor Crypto.getRandomValues() are SEEDABLE. There is no argument I could pass in that would produce the same random sequence for the same seed-value.

A reproducible random sequence would be useful in many situations I believe. I understand such a thing is not too difficult to program but it may be difficult to get verifiably good quality randomness out of your own implementation.

Re:Creating randomness Without Math.random by capableweb on Monday July 13, 2020 @06:53AM (#23819346)
It's true that the standard is currently just a recommendation, but the implementation exists in every major browser already since, and including IE 11 https://caniuse.com/#search=getRandomValues