Call to undefined function openssl_decrypt
Solution 1
I am posting this as it might be helpful to some.
- Check
extension=php_openssl.dll
is enabled in yourphp.ini
. - Check
extension_dir
is pointed correctly inphp.ini
.
If you have recently upgraded your php version and not your Apache then it might be a possibility that correct libeay32.dll
and ssleay32.dll
are not being read which is a requirement for openssl or some version mismatch is happening.
- Get latest version of
libeay32.dll
andssleay32.dll
or copy it from your php directory sayC:\php
and overwrite the files in your Apache\bin sayC:\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));
?>
Comments
-
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 over 9 yearsOP 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 over 9 yearsI´ll take a look today.
-
Wasim A. over 7 yearsI download latest libeay32 and ssleay32 dll and restart apache and it works, thanks
-
UncaAlby over 5 yearsIs 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 almost 4 yearsFor 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.