我使用vue,并在vue中引入了Base64,CryptoJS来解密3des加密数据。然后在解密过程中发生错误

时间:2018-09-21 02:22:42

标签: javascript vue.js 3des

  

这是我在vue中解密3des数据的方法代码

Decrypt3Des(ciphertext,_key, ivstr){

        const keyHex = CryptoJS.enc.Utf8.parse(_key);
          // direct decrypt ciphertext
          const decrypted = CryptoJS.DES.decrypt({
             ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
           }, keyHex, {
             mode: CryptoJS.mode.CBC,
             padding: CryptoJS.pad.Pkcs7,
             iv: CryptoJS.enc.Utf8.parse(ivstr)
          });
          return decrypted.toString(CryptoJS.enc.Utf8);

            }
      this.Decrypt3Des(mes,_key,'%cl2#w*@')
  

这是错误

core.js?0ace:478 Uncaught (in promise) Error: Malformed UTF-8 data
at Object.stringify (core.js?0ace:478)
at WordArray.init.toString (core.js?0ace:215)
at VueComponent.Decrypt3Des (onepayApp.vue?ac22:312)
at VueComponent.boundFn [as Decrypt3Des] (vue.esm.js?65d7:177)
at eval (onepayApp.vue?ac22:397)
  

我在Internet上看到3des应该首先执行Base64安装转换,否则我将报告错误,但是我已经转过身,不知道问题是什么。请指导。

0 个答案:

没有答案
相关问题