php 调用未定义的函数 openssl_decrypt

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27950428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:38:06  来源:igfitidea点击:

Call to undefined function openssl_decrypt

phpopensslphp-openssl

提问by CJ_COIMBRA

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

当我尝试使用 POST 向具有此行的脚本发出请求时:

$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

致命错误:在第 11 行调用 mypath/usuario_webservice.php 中未定义的函数 openssl_decrypt()

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?

经过一些研究,常见的原因是输入了错误的函数名称或我的 Web 服务器上没有安装 openssl 扩展。事实证明,当我与支持人员核对时,它已安装。那么,我还应该寻找什么?

回答by Sambhav Pandey

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

我发布这个是因为它可能对某些人有帮助。

  • Check extension=php_openssl.dllis enabled in your php.ini.
  • Check extension_diris pointed correctly in php.ini.
  • 检查extension=php_openssl.dll在您的php.ini.
  • 检查extension_dir在 中正确指向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.dllare not being read which is a requirement for openssl or some version mismatch is happening.

如果您最近升级了 php 版本而不是 Apache,那么可能是正确的libeay32.dll并且ssleay32.dll没有被读取,这是 openssl 的要求,或者发生了某些版本不匹配。

  • Get latest version of libeay32.dlland ssleay32.dllor copy it from your php directory say C:\phpand overwrite the files in your Apache\bin say C:\Apache24\bindirectory.
  • 获取最新版本的libeay32.dllssleay32.dll或从你的php目录中的发言权将其复制C:\php并覆盖在Apache \斌说的文件C:\Apache24\bin目录。

Hope this will help.

希望这会有所帮助。

回答by Halayem Anis

Enable this extension in your php.inifile by removing semicolon

通过删除分号在php.ini文件中启用此扩展

extension=php_openssl.dll

Restart your Apacheserver and retry
Hope that helps :)

重新启动您的Apache服务器并重试
希望有帮助:)

回答by mollywallyamma

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

我遇到了这个问题,所以我只是通过 phpseclib 使用了 Crypt_AES:

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