调用未定义函数 openssl_encrypt
Call to undefined function openssl_encrypt
我有一个使用加密 openssl 的 CMS。我用了很长时间,这个方法对我来说很管用。
在使用SSL证书和https连接构建第一页时出现问题。
加密方法代码:
$crypt = array(
'key' => 'zM6XJLg1wKWvvzhoWHM7',
'method' => 'AES-256-CBC',
'iv' => 'gantedos',
);
function eco_encrypt($string) {
global $crypt;
$output = false;
// hash
$key = hash('sha256', $crypt['key']);
$iv = substr(hash('sha256', $crypt['iv']), 0, 16);
$output = openssl_encrypt($string, $crypt['method'], $key, 0, $iv);
$output = base64_encode($output);
return $output;
}
function eco_decrypt($string) {
global $crypt;
$output = false;
$key = hash('sha256', $crypt['key']);
$iv = substr(hash('sha256', $crypt['iv']), 0, 16);
$output = openssl_decrypt(base64_decode($string), $crypt['method'], $key, 0, $iv);
return $output;
}
function eco_encrypt_md5($string) {
global $crypt;
$output = false;
$key = hash('sha256', $crypt['key']);
$iv = substr(hash('sha256', $crypt['iv']), 0, 16);
$output = openssl_encrypt($string, $crypt['method'], $key, 0, $iv);
$output = base64_encode($output);
return md5($output);
}
现在当我通过 https:// 连接时收到错误:
Fatal error: Call to undefined function openssl_encrypt() in ...
我不知道如何解决这个问题,因为我真的很想保留这种加密方式。
这可能吗?请任何建议、建议或其他加密方法。
感谢@Artjom B!
PHP 版本在 https 连接上更改。
在 http 上是 5.6.19,在 https 上是 5.2.17
我有一个使用加密 openssl 的 CMS。我用了很长时间,这个方法对我来说很管用。
在使用SSL证书和https连接构建第一页时出现问题。
加密方法代码:
$crypt = array(
'key' => 'zM6XJLg1wKWvvzhoWHM7',
'method' => 'AES-256-CBC',
'iv' => 'gantedos',
);
function eco_encrypt($string) {
global $crypt;
$output = false;
// hash
$key = hash('sha256', $crypt['key']);
$iv = substr(hash('sha256', $crypt['iv']), 0, 16);
$output = openssl_encrypt($string, $crypt['method'], $key, 0, $iv);
$output = base64_encode($output);
return $output;
}
function eco_decrypt($string) {
global $crypt;
$output = false;
$key = hash('sha256', $crypt['key']);
$iv = substr(hash('sha256', $crypt['iv']), 0, 16);
$output = openssl_decrypt(base64_decode($string), $crypt['method'], $key, 0, $iv);
return $output;
}
function eco_encrypt_md5($string) {
global $crypt;
$output = false;
$key = hash('sha256', $crypt['key']);
$iv = substr(hash('sha256', $crypt['iv']), 0, 16);
$output = openssl_encrypt($string, $crypt['method'], $key, 0, $iv);
$output = base64_encode($output);
return md5($output);
}
现在当我通过 https:// 连接时收到错误:
Fatal error: Call to undefined function openssl_encrypt() in ...
我不知道如何解决这个问题,因为我真的很想保留这种加密方式。
这可能吗?请任何建议、建议或其他加密方法。
感谢@Artjom B! PHP 版本在 https 连接上更改。 在 http 上是 5.6.19,在 https 上是 5.2.17