3 ms·
A PRNG based on RC4 should be very fast but much more secure than a MT or a LCG. EDIT: also it is very important to seed with care if you are interested in sec
by antirez 14y ago
A PRNG based on RC4 should be very fast but much more secure than a MT or a LCG.
EDIT: also it is very important to seed with care if you are interested in security. Even a strong PRNG seeded with seed_prng(time(NULL)) will be an easy target for brute force attacks.
At least /dev/urandom should be used for seeding purposes in applications where you need an unguessable PRNG.
- tptacek 14y agoRC4-based CSPRNGs were an OpenBSD idiom. But you should use your OS's or your framework's secure random number generator in preference to arc4random(), because there's more to the security of a good CSPRNG than just the algorithm it to jumble up its internal state.
- carbocation 14y ago> At least /dev/urandom should be used for seeding purposes in applications where you need an unguessable PRNG. I usually consume /dev/urandom and convert it to the base I require, using that directly as my random number. When you say you should use it for seeding purposes, are you referring to using /dev/urandom as a seed for something like PHP's rand(), or do you mean something else?
- tptacek 14y agoSeeding is largely a problem you have if you're building (or retrofitting in) your own CSPRNG, which you shouldn't do. The random/urandom interface Unixes provide will allow you to shovel in high-entropy data, but I think you're more likely to do harm than good (it's a marginal impact in either direction, though). You're doing the right thing already.
- carbocation 14y agoAha, that makes sense. Thanks!