我在项目服务器上使用openssl_encrypt / openssl_decrypt库(Ubuntu 16.04 + PHP5.6)。该脚本一直工作正常,直到上周我在服务器上安装了php-Imap库,脚本现在无法使用OpenSSL加密/解密代码。
我编写了如下最简单的测试代码来测试PHP-OpenSSL库:
<?php
$algorithm = 'AES-128-CBC';
$arr = 'this is a test...';
$iv = '1234123412341234';
$key = 'aslfkkasdsalklkdasflwefwewfloiuy';
$encrypt = openssl_encrypt(json_encode($arr), $algorithm, substr($key, 0, 16), 0,$iv);
$decrypt = json_decode(openssl_decrypt($encrypt, $algorithm, substr($key, 0, 16), 0,$iv));
var_dump($encrypt, openssl_error_string(), $decrypt );
exit;
它在我的机器上成功执行,但无法在服务器上执行,服务器上的执行结果是:
$ php test.php
bool(false)
bool(false)
NULL
Ubuntu服务器上的PHP信息是:
有人有任何建议吗?