6

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?

4

3 回答 3

15

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

  • 检查extension=php_openssl.dll已在您的php.ini.
  • 检查extension_dir正确地指向php.ini

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

  • 从您的 php 目录获取最新版本libeay32.dllssleay32.dll/或复制它,C:\php并覆盖您的 Apache\bin sayC:\Apache24\bin目录中的文件。

希望这会有所帮助。

于 2016-07-30T17:20:42.110 回答
3

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

extension=php_openssl.dll

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

于 2015-01-14T19:02:13.250 回答
2

我遇到了这个问题,所以我只使用了 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));
?>
于 2015-01-15T02:33:25.323 回答