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!