Call to undefined function openssl_decrypt

吃可爱长大的小学妹 提交于 2020-05-27 05:27:18

问题


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?


回答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.




回答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 :)




回答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));
?>


来源:https://stackoverflow.com/questions/27950428/call-to-undefined-function-openssl-decrypt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!