I have found an script that will randomly generate numbers/letters for an X amount.
It works fine on my localhost however when I upload the script to my VPS it does not work.
I get following error:
Fatal error: Call to undefined function openssl_random_pseudo_bytes()
That would be this part of code:
function crypto_rand_secure($min, $max) {
$range = $max - $min;
if ($range < 0) return $min; // not so random...
$log = log($range, 2);
$bytes = (int) ($log / 8) + 1; // length in bytes
$bits = (int) $log + 1; // length in bits
$filter = (int) (1 << $bits) - 1; // set all lower bits to 1
do {
$rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));
$rnd = $rnd & $filter; // discard irrelevant bits
} while ($rnd >= $range);
return $min + $rnd;
}
I have found an post on stacksoverflow with the same issue. However it required an module installed. I am not sure how do I do this, but i have found this on my WHM of VPS.
Home »Software »Module Installers
When I choose Perl Module and search for openssl, I get many results.
I have installed one of these, and I had installed one by default.
Here are installed openssl modules:
Crypt::OpenSSL::RSA
Crypt::OpenSSL::Random
Still… I get the same error on my website.
Any solution? Thanks in advance.
The OpenSSL Perl modules you found are a red herring. They have no effect whatsoever on PHP. (PHP and Perl are two entirely separate programming languages.)
What you need to install is the openssl PHP module. I don’t recall exactly whether cPanel has an option to rebuild PHP, but if I’m right and it does, you’ll need to go through that process and enable OpenSSL there.