top | item 26104879

(no title)

zinkem | 5 years ago

I most commonly use random() for generating names (e.g. docker's container names) and generating test inputs. I don't care about cryptographic safety in either case.

discuss

order

tatersolid|5 years ago

But you probably care about collisions in that case. The small state of a language-default insecure PRNG will make collisions much more likely. Especially if seeded by a clock.

I have seen temp file name collisions cause data corruption in a real system because the default language RNG was used. Also infinite loops in a production system because random() was called in the same clock tick by two separate threads generating a handle value. Both wasted weeks of effort to pin down.

random() should default to the system CSPRNG. Provide insecureFastRandom() for those who know they need it and it is safe for their use.

iainmerrick|5 years ago

I wouldn’t imagine you care that much about speed either, right? Unless you’re generating gigabytes of random test data, maybe.