php - 调用未定义函数 openssl_encrypt

标签 php ssl encryption https php-openssl

我有一个使用加密 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 :在 ... 中调用未定义的函数 openssl_encrypt()

我不知道如何解决这个问题,因为我真的很想保留这种加密方式。

这有可能吗?请提出任何建议、提案或其他加密方法。

最佳答案

感谢@Artjom B! PHP 版本在 https 连接上发生了变化。 在 http 上是 5.6.19,在 https 上是 5.2.17

关于php - 调用未定义函数 openssl_encrypt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39933605/

相关文章:

ruby-on-rails - Ruby 中的 Mechanize 和 SSLError

java - 在使用 Java 8 重新协商 TLS_1.2 期间,服务器证书更改受到限制

iis - 如何将自签名 SSL 证书部署到多个服务器

objective-c - AFNetworking + RNCryptor - 在 JSON 解析之前解密数据

java - 如何在android中使用RSA进行加密和解密

php - 将表列中的 DEC 值转换为十六进制

javascript - 使用复选框提交表单

ruby-on-rails - 在内存 Ruby/Rails 中压缩和加密文件

javascript - 按数字处理输入字段

php - CakePHP 导入的 Controller 作用域问题