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));
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.