note 25034 deleted from function.shuffle by jimw
| From: | jimw@php.net | Date: | Sun, 08 Sep 2002 16:57:45 +0000 |
| Subject: | note 25034 deleted from function.shuffle by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-36351@lists.php.net to get a copy of this message | ||
Why does the doc still says that one must use srand() prior to use shuffle() ?
srand() is very bad, as it requires an entropy source, and even microtime() is not a good one.
Since PHP 4.2, rand() is now automatically initialized with a good entropy source at first
invokation of rand(), and you should not call srand().
If shuffle() does not initialize the generator, one can simply call rand(), not srand(), to
initialize the generator!
the rand() and mt_rand() packages should really specify another way to initialize their generator
than, srand() and mt_srand() that accept only an int value...
Why srand() and mt_srand() don't they accept _arbitrary long_ strings or arrays of data, that
we could simply use to feed the generator with multiple entropy sources ?