0

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.

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

You need also to compile php with --with-openssl as stated in http://php.net/manual/en/openssl.installation.php.

Comments

1

I had the same issue myself. I solved it by editing my php.ini file - changing ;extension=php_openssl.dll to extension=php_openssl.dll .

(For my installation, my php.ini file was located in my P:\Program Files\EasyPHP-12.1\conf_files\ directory.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.