diff options
author | Joey3000 <Joey3000@users.noreply.github.com> | 2016-01-16 11:20:08 +0300 |
---|---|---|
committer | Joey3000 <Joey3000@users.noreply.github.com> | 2016-01-16 11:20:08 +0300 |
commit | bc06df85ccaf4faf68f7004d2853c304da959cb0 (patch) | |
tree | 8576afa9d2f72941ce29efa11d4ee8fc9ad76333 /core/Common.php | |
parent | bdf5809c660fab8bb7ae4cbd1757cb9d30d61388 (diff) |
Remove PRNG seeding
This is done for the following reasons:
* Code clean-up. From https://secure.php.net/manual/en/function.mt-srand.php:
> Note: There is no need to seed the random number generator with srand() or mt_srand() as this is done automatically.
* Re-seeding of PRNGs makes them more predictable. E.g., the `microtime()` which is used for the seeding:
* On Windows (before Win8): seems to return 0, according to https://stackoverflow.com/questions/18889244/php-5-5-on-windows-microtime-behavior.
* On other OSes: The current time is easily guessable, with the "microseconds" part brute-forcible.
Diffstat (limited to 'core/Common.php')
-rw-r--r-- | core/Common.php | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/core/Common.php b/core/Common.php index c6e0247941..7992275a56 100644 --- a/core/Common.php +++ b/core/Common.php @@ -584,10 +584,6 @@ class Common $chars = $alphabet; $str = ''; - list($usec, $sec) = explode(" ", microtime()); - $seed = ((float)$sec + (float)$usec) * 100000; - mt_srand((int) $seed); - for ($i = 0; $i < $length; $i++) { $rand_key = mt_rand(0, strlen($chars) - 1); $str .= substr($chars, $rand_key, 1); |