rfc:improve_predictable_prng_random

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:improve_predictable_prng_random [2017/02/03 05:22] – Add reseed logic yohgakirfc:improve_predictable_prng_random [2018/03/01 23:13] (current) – RFC is Under Discussion carusogabriel
Line 3: Line 3:
   * Date: 2017-02-01   * Date: 2017-02-01
   * Author: Yasuo Ohgaki <yohgaki@ohgaki.net>   * Author: Yasuo Ohgaki <yohgaki@ohgaki.net>
-  * Status: Draft+  * Status: Under Discussion
   * First Published at: http://wiki.php.net/rfc/improve_predictable_prng_random   * First Published at: http://wiki.php.net/rfc/improve_predictable_prng_random
  
Line 136: Line 136:
       if ($this->reseed && !($this->count % $this->reseed)) {       if ($this->reseed && !($this->count % $this->reseed)) {
         $this->seed();         $this->seed();
 +        $this->count = 1;
       }       }
     }     }
Line 218: Line 219:
 </code> </code>
  
-uint32_t BG(mt_rand_is_seeded) is used for already seeded flag and counter. Upper 16 bits are used for seeded flag, lower 16 bits are used for counters. Therefore, max reseed count is 2^16.+uint32_t BG(mt_rand_is_seeded) is used for already seeded flag and counter. MSB is used for seeded flag, the rest bits are used for counters. Therefore, max reseed count is 2^31.
  
  
Line 226: Line 227:
 mt_srand()/srand() returned nothing previously. mt_srand()/srand() returned nothing previously.
  
-If users want static random values, they have to use RandomStatus object to get it. Use of mt_srand()/srand() would be rare in general.+If users want static random values, they have to use Random object to get certain random sequence. i.e. Call mt_srand()/srand() for Random object, then use it with functions, rand()/mt_rand()/shuffle()/etc. Use of mt_srand()/srand() would be rare in general.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
rfc/improve_predictable_prng_random.1486099364.txt.gz · Last modified: 2017/09/22 13:28 (external edit)