nodejs 解密aes 报错

stephen2017
  • 1
新手上路,请多包涵

源码

 JM: function JM(e) {
                var t = this.getKey(), n = new Date().getTime().toString(), r = a.a.enc.Utf8.parse(t + n);
                "object" == (void 0 === e ? "undefined" : s(e)) && (e = JSON.stringify(e));
                var o = a.a.AES.encrypt(e, r, {
                    iv: r,
                    mode: a.a.mode.CBC,
                    padding: a.a.pad.Pkcs7
                }).toString(), i = a.a.AES.decrypt(o.toString(), r, {
                    iv: r,
                    mode: a.a.mode.CBC,
                    padding: a.a.pad.Pkcs7
                }).toString(a.a.enc.Utf8);
                return {
                    data: o,
                    time: n,
                    decryData: "string" == typeof i ? i : JSON.parse(i)
                };
            },
function data_dencrypt()
{  
    data='zRuujcI5XEbYqvgx4pPMOA1cYSrGRNjlw9+PYMFwrQ140Abp5uJ7micdHwq0Z5u6UOO8Bl4TXCYU3rN6yUoSxbYKSAX6K6InfUTveWaOoEJIYLVJJeGsamJl6Cj1gtmnOuZnbqzQzf7TPU0r4FvbYIN+Homn0G0tnWp9jnTPUAJ0JTzG3CK4V3FvRF1ifNUugQobFLdP/pW/v9ryLqYZacgnFp6XddKKoPoFn5+ZMGquTbiL9OPdQ77ia+EmKlRVXcUC7gYQNF+Qyvxn9GmLvRIW5uGMaQHpRNiffEg9j3dsFGOBlDpf8JNxcUPvnqYlj6SAv25+TBEBr7/O8xzXPG3Bsyj8kJDc37Ojnk6F+LN8a6D3ql2JtYmYfZ8vdpkIobtFolTF+jyFGNmoiIuZO6Sm7rG3HntYLChh9E16yJ1yERqPUzkdVv1u43ENz+Pj2JBFAw+l0O67D25nQVtDPPBIBtEcSs3QsAiw0ARWkbZS+cdsT4Gi/1xb0Opc92Z1xPcrvy/lexI0sT/DH5HexEWeM3UUqUejpEPVpyInCnGr+6A3yb5xR7PAvKjBNdaL8caKGBwRyERFdBsJ5eMWRiWtLhMLLXYyWeFh7cMUZopZAAh9IWAMFhUZk1mAnrNi+aBQJwvH1qAgkUWF5GRizmlRf/mo1mdc2+xo11IGdgPi+VpKYOxitiITXyLHyGBRCO2RSh5pr9ju0an8D9wqKgFCLNcMwCwAEwRs4QUk9FIYhPnvVMq3LUiVvuqsWjtja8iBxWsz+H5/h3TFWfXi/Qy9o94OY1b2xKxdKjXs/26STSaBYGvzrO27EtmYJPYISQUHku96FeXFtc9bd23sGanSfiDeemoAsPLEnfm1iznVECFm3VwJn14CTZpk9dHJp6DLbhuV6AzX6cQftDRyAbwGvGibDTZiVjMBvLUpm5mIX6yE9LwYy9sM1NqV2H3ksLjnrr75cEKUHNWAOpKS9ZGQrHLCaloXFNTqqn5939Y3ECOk25VEbc8CpnBC1UApd+fDVZV68UTLyakVCJdxka7k4+zag5UuX4MlbH1cYhynzE2oziChwLc/pV2exc3oaQYrg1LrN0yj0Bix3Oruwh9rR6Mpa53OWWGDtdLrSXQgjFC3CCTSwXnrqkMb/Q6pcxMYSUHcesNrcl09fbLRsg=='
    var t = 'E6C'
    var n = new Date().getTime().toString()
    varkey  = CryptoJS.enc.Utf8.parse(t + n);
    var iv =varkey

    var uuData=CryptoJS.enc.Utf8.parse(data);
    Decryptor = CryptoJS.AES.decrypt(uuData.toString(), varkey, { iv: iv,mode:CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7});
    dataStr=Decryptor.toString(CryptoJS.enc.Utf8)
    return dataStr

}
var result=data_dencrypt()
console.log(result)

malform utf-8报错
报错如下

image.png

回复
阅读 250
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏