dominictarr/crypto-browserify — pull request #29 by tonistiigi (2013-11-26 09:50:10+00:00)
Title: Fix random generator for more than 16 bytes #28

Note that I switched to Uint8 only for simplicity. I don't think there was a bug in slicing 32 bits to 4 bytes.

@dominictarr This is pretty bad bug so maybe a note in readme or a tweet is a good idea. If someone used it to generate more than 16 bytes they should overlook their code.

--

I also looked at the `Math.random()` version and maybe we could do better in there as well. I would rather call `Math.random` for every byte than to use one result for 4 bytes. Other implementations I've seen have used multiply of many `Math.random()` results or xor with a timebyte taken from `performance.now` or `new Date`