Re: Re: Reseeding rand()/mt_rand()
| From: | Andrea Faulds | Date: | Tue, 31 Jan 2017 20:48:58 +0000 |
| Subject: | Re: Re: Reseeding rand()/mt_rand() | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-98093@lists.php.net to get a copy of this message | ||
Hi,
Yasuo Ohgaki wrote:
My current objective is to make existing API to work, so resource may be used to set/get PRNG state.I would prefer it if we not introduce a new usage of resources. An object would suffice.
*** Initialize and Create new PRNG state resource *** resource mt_srand([int|string $seed]) resource: MT rand state resource. $seed: I would like to allow large seed like Python and Ruby.While we could retrofit this into the existing API, it would be cleaner and friendlier to provide a new one based on objects. -- Andrea Faulds https://ajf.me/When seed is string, use all bits for MT rand stateinitialization.Example usage: mt_srand(random_bytes(2000));*** Get random number from state resource *** int mt_rand() // System state int mt_rand(resource $state) // Specified user state int mt_rand(int $min , int $max [,resource $state]) // Specified user state if $state is passed