[ILUG-BOM] Re: random no generation issues
vinayak_hegde at antispam
Thu Mar 13 12:02:43 IST 2003
Philip S Tellis writes:
> On Wed, 12 Mar 2003, Manish Jethani wrote:
>> Ok, I get the idea. Use rand() instead, for portability. And
>> you have to seed the random no. generator with, say, the current
>> time. Seed it using srandom((unsigned) time(NULL)) before any
>> calls to random().
> Althought that is what I do, someone once said that it's a bad idea to
> seed the random number generator with the system time.
>> > or does someone have a better idea of generating random nos?
especially if you use it to generate the key for encryption. For the
attacker, it narrows down the search for the random number generated key.
from the random manpage (man 4 random):
The random number generator gathers environmental noise from device
drivers and other sources into an entropy pool. The generator also
keeps an estimate of the number of bit of the noise in the entropy
pool. From this entropy pool random numbers are created.
This is a good way to generate high quality random numbers.
More information about the Linuxers