Help with script migration Javascript -> CF worker

Hey i can do it in CF workers, but it’s hard for me… i trying Web Crypto, but stil have errors.

In JavaScript i have only password and text to encrypt and it’s all, in CF… i don’t know what’s going on.

Someone can convert my script to CF worker? I wanna get simple effect, every request i will get encrypted password.

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script>
<script>
    var key = "pass123";
    var toen = 'testvaluetoencrypt';
    var encrypted = CryptoJS.AES.encrypt(toen, key);
    var output = encrypted.toString();
    document.write(output);
</script>

Best Regards