Re: Re: Seeding rand() at process start?

From: Date: Fri, 21 Sep 2001 16:28:41 +0000
Subject: Re: Re: Seeding rand() at process start?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-66295@lists.php.net to get a copy of this message
That's not the point. If PHP seeds the random number generator at MINIT time, with a "pretty good random seed" it will save a lot of work for devlopers tying to use rand() to come up with a good random number. As it is now, they need some sort of flag that indicates that they have seeded the random generator in this process, or find some sort of way of repeatedly seeding the generator. Either way, rand() is "useless" without a proper seed and it is difficult create a good seed in PHP. > On Fri, 21 Sep 2001 09:09:07 -0400 (EDT) > mlwmohawk@mohawksoft.com wrote: > > :Does it make sense for PHP to seed rand() with srand() when it starts > up, :during MINIT in basic_functions.c? > : > :It just seems that there is no good way to ensure you have a good seed > for :random, and if rand() were "ready to use, out of the box" a lot of > people :would not be pulling their hair out trying to fabricate a clean > seed. :Besides one should seed only once, more often than that > circumvents the :"randomness" of a random number generator. > : > :On UNIX we could seed rand() with /dev/urandom, else we could use time > of :day. (Any other suggestions would be welcome.) > > <http://www.fourmilab.ch/hotbits/> > > You can pick up as many random bytes as you want; usually use a 16-bit > INT as a seed. > > -- > Tony Reed > <trljc@altern.org> > "The President was assassinated by a precision guerrilla team of at > least seven men ..." -- Jim Garrison > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net

« previous php.dev (#66295) next »