解密加密字符串后,我无法使用json_decode()函数解码json
这是我的加密和解密代码
function encrypt($s, $key = "", $iv = "") {
if (strlen($key) == 0)
$key = $this->default_key;
if (strlen($iv) == 0)
$iv = $this->default_iv;
$iv_utf = mb_convert_encoding($iv, 'UTF-8');
return base64_encode(mcrypt_encrypt($this->mcrypt_cipher, $key, $s, $this->mcrypt_mode, $iv_utf));
}
function decrypt($s, $key = "", $iv = "") {
if (strlen($key) == 0)
$key = $this->default_key;
if (strlen($iv) == 0)
$iv = $this->default_iv;
$iv_utf = mb_convert_encoding($iv, 'UTF-8');
return mcrypt_decrypt($this->mcrypt_cipher, $key, base64_decode($s), $this->mcrypt_mode, $iv_utf);
}
解密输出看起来很好(输出为{“stage_index”:“0”}) 但我无法解码到json它总是返回NULL,我不知道为什么:(