Workers CryptoJS Example

Hi,

How can I use CryptoJS inside of a Cloudflare Worker? What I’m trying to do is replicate this function:

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js"></script>
<script>
var key = CryptoJS.enc.Utf8.parse('ds8am3wys3pd75nf0ggtvajw2k3uny92');     // Use Utf8-Encoder. 
var iv  = CryptoJS.enc.Utf8.parse('jm8lgqa3j1d0ajus');                     // Use Utf8-Encoder

var encryptedCP = CryptoJS.AES.encrypt("2730007809303", key, { iv: iv });
var decryptedWA = CryptoJS.AES.decrypt(encryptedCP, key, { iv: iv});

var encryptedBase64 = encryptedCP.toString();                              // Short for: encryptedCP.ciphertext.toString(CryptoJS.enc.Base64);
var decryptedUtf8 = decryptedWA.toString(CryptoJS.enc.Utf8);               // Avoid the Base64 detour.
                                                                           // Alternatively: CryptoJS.enc.Utf8.stringify(decryptedWA);  
console.log("Ciphertext (Base64)  : " + encryptedBase64)
console.log("Decrypted data (Utf8): " + decryptedUtf8); 
</script>

I found a great link with examples on Crypto using Cloudflare workers here: Adding examples to Web Crypto · Issue #11293 · cloudflare/cloudflare-docs · GitHub

But I can’t figure out how to make the above function, inside of Cloudflare. I specifically need a ‘key’, an ‘iv’ and input data.

Please help? Here are a bunch of non working examples that I can’t get correct yet: Aes-256-cbc decode example - #9 by v.sobolev