Bug #68959 [Opn->Nab]: limit rand() function
| From: | nikic@php.net | Date: | Fri, 30 Jan 2015 20:22:38 +0000 |
| Subject: | Bug #68959 [Opn->Nab]: limit rand() function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190358@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68959&edit=1
ID: 68959
Updated by: nikic@php.net
Reported by: peter dot mlich at volny dot cz
Summary: limit rand() function
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: win
PHP Version: 5.5.21
Block user comment: N
Private report: N
New Comment:
rand() exposes the libc rand source and Windows is notable for providing a very weak linear
congruential generator. If you want to get stronger random numbers, use mt_rand(), which is based on
MT19937. Note that they aren't cryptographic in any case.
Previous Comments:
------------------------------------------------------------------------
[2015-01-30 09:38:03] peter dot mlich at volny dot cz
Description:
------------
After about 32000 function rand() repeating number (or zero?) as pattern. Array can be easy
compressed by gzip.
If you understand about compression, this is critical bug. I test array with 10.000 numbers, gzip
compress to 33%. Other script with no rand() with read from file compress about 100.5% (my compress
script about 95%).
I cant use random data generator, if repeating as pattern which can easy compress with php-gzip.
php 5.3.5, wamp server 2.1
php 5.5.12, wamp server 2.5
Test script:
---------------
$max = 32000;
$max = 100000;
$arr = array();
for ($i=0;$i<$max;$i++)
{
$arr[$i] = rand(0,255);
}
return $arr;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68959&edit=1