On Fri, 21 Sep 2001 [EMAIL PROTECTED] wrote:

> 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.
>

    srand();

    As of the CVS version of PHP, if you leave the seed out, the rand
    implementation will autogenerate it for you (it really wasn't that
    hard beforehand, but...)

    I'm currently debating whether seeding at startup is a good idea,
    because alot of scripts don't use rand() (alot do I know, but
    still), and seeding at startup will cause a slow down in PHP...
    another thought is to have rand() check whether or not its been
    seeded, and if it has been seeded, use the previous seed, otherwise,
    seed the generator (I'm currently leaning towards the latter).

    -Sterling

>
> > On Fri, 21 Sep 2001 09:09:07 -0400 (EDT)
> >   [EMAIL PROTECTED] 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
> > <[EMAIL PROTECTED]>
> > "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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail:
> > [EMAIL PROTECTED]
>
>
>
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to