Cryto-JS uses CBC-Mode as default, while Lucee using ECB.
You need to change to mode and than it works.
Example:
<cfset encryptKeyClear = "TestTestTestTest" />
<cfset encryptKey = tobase64(encryptKeyClear) />
<cfset encryptContent = encrypt("TestString", encryptKey, "AES", "Base64") />
<cfdump var="#encryptContent#" label="Content" />
<cfset decryptContent = decrypt(encryptContent, encryptKey, "AES", "Base64") />
<cfdump var="#decryptContent#" label="Decode-Content"/>
<cfoutput>
<script src="crypto-js-3.1.9-1/crypto-js.js"></script>
<script>
let encryptContent = '#encryptContent#';
let encryptKey = CryptoJS.enc.Base64.parse('#encryptKey#');
console.log('Content', encryptContent);
let decryptBytes = CryptoJS.AES.decrypt(encryptContent, encryptKey, {
mode: CryptoJS.mode.ECB
});
console.log('Decode-Content', decryptBytes.toString(CryptoJS.enc.Utf8));
</script>
</cfoutput>
Just for my pure of interest, why do you want to encrypt and decrypt directly after that ajax-request?
When you are using a SSL-Connection the data is already transferred encrypted.