Call to undefined function openssl_decrypt

38,470

Solution 1

I am posting this as it might be helpful to some.

  • Check extension=php_openssl.dll is enabled in your php.ini.
  • Check extension_dir is pointed correctly in php.ini.

If you have recently upgraded your php version and not your Apache then it might be a possibility that correct libeay32.dlland ssleay32.dll are not being read which is a requirement for openssl or some version mismatch is happening.

  • Get latest version of libeay32.dlland ssleay32.dll or copy it from your php directory say C:\php and overwrite the files in your Apache\bin say C:\Apache24\bin directory.

Hope this will help.

Solution 2

Enable this extension in your php.ini file by removing semicolon

extension=php_openssl.dll

Restart your Apache server and retry
Hope that helps :)

Solution 3

i had this problem so i just used Crypt_AES by phpseclib:

<?php
include('Crypt/AES.php');

$cipher = new Crypt_AES(); // it's cbc by default
$cipher->setKeyLength(256);
$cipher->setKey('abcdefghijklmnopijklmnopqrstuvwxyz3456');

$size = 10 * 1024;
$plaintext = str_repeat('a', $size);

echo $cipher->decrypt($cipher->encrypt($plaintext));
?>
Share:
38,470
CJ_COIMBRA
Author by

CJ_COIMBRA

Native Mobile Developer / Hobbyist Game Developer

Updated on July 05, 2022

Comments

  • CJ_COIMBRA
    CJ_COIMBRA almost 2 years

    When I try to make a request with POST to a script that has this line:

    $decrypted_data = openssl_decrypt($encrypted_data, 'AES-256-CBC', $key);
    

    I get the following error:

    Fatal error: Call to undefined function openssl_decrypt() in mypath/usuario_webservice.php on line 11

    After some research the common reasons would be entering the wrong name for the function or the openssl extension not being installed on my web server. It turns out that it is installed as I checked with the support. So, what else should I be looking for?

  • iam-decoder
    iam-decoder over 9 years
    OP had to contact support, so I'm assuming he is having this problem on the hosting server, and may not have access to the php.ini file (depending on the type of hosting they have) so this post may prove to be incorrect.
  • CJ_COIMBRA
    CJ_COIMBRA over 9 years
    I´ll take a look today.
  • Wasim A.
    Wasim A. over 7 years
    I download latest libeay32 and ssleay32 dll and restart apache and it works, thanks
  • UncaAlby
    UncaAlby over 5 years
    Is this compatible with the encryption from OpenSSL? It is important to be able to decrypt data on one machine that was encrypted on another.
  • Will
    Will almost 4 years
    For those who are still looking into this, note that since version 1.1.0, the library names have changed. libeay32.dll becomes libcrypto-1_1.dll and ssleay32.dll becomes libssl-1_1.dll. As indicated in this answer, both files should be in your PHP directory.