The front-end javascript is encrypted with CryptoJS, and then decrypts the ciphertext. Why is the decryption empty?

the front-end javascript is encrypted with CryptoJS, and then decrypts the ciphertext. Why is it empty?

the following is the code written:

import CryptoJS from "crypto-js";

const key = CryptoJS.enc.Utf8.parse("1234123412ABCDEF");
const iv = CryptoJS.enc.Utf8.parse("ABCDEF1234123412");

// 
function Encrypt (data) {
    let srcs = CryptoJS.enc.Utf8.parse(data);
    let encrypted = CryptoJS.AES.encrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.ciphertext.toString().toUpperCase();
}

// 
function Decrypt (data) {
    let encryptedHexStr = CryptoJS.enc.Hex.parse(data);
    let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
    let decrypt = CryptoJS.AES.decrypt(srcs, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7
    });
    let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
    return decryptedStr.toString();
}

export default {
    Encrypt,
    Decrypt
};

has tried many ways, but the decryption is empty, ask God for advice!


I think you need to track whether the function call was successful.
decryption is whether the data is input
Let's see if and what the encrypted output is, and then decrypt it.
as long as there is data input in decryption, there should be output (possibly incorrect) ah (unless there is no input)

https://www.jianshu.com/p/a47477e8126a has a similar code, which you can refer to.


I tried to figure it out, so why is it empty
http://jsfiddle.net/egbp7c95/3/

?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31f31-2ab1c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31f31-2ab1c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?