I need to generate uncompressible data (therefore pseudorandom), and have been trying with the code below. But it's only producing about 10MB/s of data. I need about 100-200 MB/s. Do you have any advice?
if ($length > 8*1024*1024){ //Default max string length in php.
while (($length - $bytesGenerated)>8*1024*1024){
$bytesGenerated = $bytesGenerated + (8*1024*1024);
print(openssl_random_pseudo_bytes(8*1024*1024));
}
}
print(openssl_random_pseudo_bytes($length - $bytesGenerated));
The rand() function generates a random integer. Example tip: If you want a random integer between 10 and 100 (inclusive), use rand (10,100). Tip: As of PHP 7.1, the rand() function has been an alias of the mt_rand() function.
rand() or mt_rand() functions can be used to Generate 5 Digit Random Number in PHP.
php $check = array(); function generateNumber() { global $check; $page_no = mt_rand(1,20); $check[] = $page_no; if (count($check) !=
Generate 4 Digit Random Number using mt_rand() mt_rand() function is just like rand() function but it is 4 times faster than rand() function. To use mt_rand() function define min and max numbers. The mt_rand() function will return a random integer between min and max numbers (including min and max numbers).
if you are working under linux you could just read from /dev/urandom, its kernels fast pseudorandom generator.
on the other way you could use openssl rand and pipe that into php.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With