1 回答
TA贡献1735条经验 获得超5个赞
您的密钥和 IV 是十六进制编码的,因此要解析它们,您需要使用CryptoJS.enc.Hex.parse() 而不是CryptoJS.enc.Utf8.parse():
function getDecryptedCode() {
var key = CryptoJS.enc.Hex.parse(
"814591256d331af80bec0fa2bef1123e37e9f181f363af374787e24160275bce"
);
var iv = CryptoJS.enc.Hex.parse("825b1f7c5f5edd614e8a0a0fef3c9ecf");
var ciphertext = CryptoJS.enc.Base64.parse("07KxrSbGIoPCIYh0I16maw==");
var encryptedCP = CryptoJS.lib.CipherParams.create({
ciphertext: ciphertext,
formatter: CryptoJS.format.OpenSSL
});
var decryptedWA = CryptoJS.AES.decrypt(encryptedCP, key, {
iv: iv
});
var decryptedUtf8 = decryptedWA.toString(CryptoJS.enc.Utf8);
return decryptedUtf8;
}
console.log(getDecryptedCode()); // 496271
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"></script>
添加回答
举报