Re: Re: Improving mt_rand() seed

From: Date: Wed, 18 Jan 2017 17:27:33 +0000
Subject: Re: Re: Improving mt_rand() seed
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-97861@lists.php.net to get a copy of this message
On 18 January 2017 at 16:06, Lauri Kenttä <lauri.kentta@gmail.com> wrote: > > If it's not acceptable to randomize the whole state, I'd recommend using > php_random_int_silent() to generate a single seed. This would be easy to > implement by simply changing GENERATE_SEED() into a function which first > tries php_random_int_silent() but has the current method as a fallback. This > would fix other use cases of GENERATE_SEED() as well. You don't need to use the random_int functions, 4 bytes from php_random_bytes_silent cast into a uint32_t will give you an unbiased seed. (powers of 2 are unbiased)

« previous php.internals (#97861) next »