The front-end js uses crypto-js for aes decryption, and the decrypted content is empty.

getCode() {
      let data = "qN49G7bBKHBJpl3mTfwyYA=="
      let key = "bluedon"
      let iv = "0102030405060708"

      let str = this.getDAesString(data, key, iv)
      this.$message.success(str)
    },
    getDAesString(encrypted, key, iv) {
      // 
      var ikey = CryptoJS.enc.Utf8.parse(key)
      var iiv = CryptoJS.enc.Utf8.parse(iv)
      var decrypted = CryptoJS.AES.decrypt(encrypted, ikey, {
        iv: iiv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
      })
      console.log(decrypted.toString(CryptoJS.enc.Utf8))
      return decrypted.toString(CryptoJS.enc.Utf8) //
    }
The

project is written by vue, so the decrypted console.log is empty. After reading it many times, the ciphertext and key/ ivvalue can be transferred on the online website, but I can"t get the result. That"s what it says on the Internet.

Mar.03,2021

import CryptoJS from "crypto-js";
 //
const CRYPTOJSKEY= "abcdefghighkml";
 
export default {
  
  //
  /*
  * {param} plaintText 
  * return  str 
  */
  encrypt(plaintText) {
    var plaintText = plaintText;
    var options = {
      mode: CryptoJS.mode.ECB,
      padding: CryptoJS.pad.Pkcs7
    };
    var key = CryptoJS.enc.Utf8.parse(CRYPTOJSKEY);
    var encryptedData = CryptoJS.AES.encrypt(plaintText, key, options);
    var encryptedBase64Str = encryptedData.toString();
    return encryptedBase64Str;
  },
  //
  /*
  * {param} plaintText 
  
  * return  str 
  */
  decrypt(encryptedBase64Str, type) {
   
    var encryptedBase64Str = encryptedBase64Str;
    var options = {
      mode: CryptoJS.mode.ECB,
      padding: CryptoJS.pad.Pkcs7
    };
    var key = CryptoJS.enc.Utf8.parse(CRYPTOJSKEY);
    // 
    var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, options);
    // Utf8
    var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8);
    return decryptedStr ;
  }
};

use

 //
 import Util from "util";
 //
 let userPwd = Util.encrypt('123456');

the reason I decrypted it empty is because of the length of the key.


with length requirements
  aes encryption and decryption  tried, but it is really empty, as you said about the key length problem. 

Menu