0

解密加密字符串后,我无法使用 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,我不知道为什么:(

4

0 回答 0