let plain_text_message = "abc!?";
let passphrase = "your passphrase";
console.log("Encrypting message:", plain_text_message);
let encrypted = CryptoJS.AES.encrypt(plain_text_message, passphrase);
let encrypted_as_string = encrypted.toString(); // here I would like to specify and encoding, for example CryptoJS.enc.Base64
console.log("Encrypted message:", encrypted_as_string);
let decrypted = CryptoJS.AES.decrypt(encrypted, passphrase);
let decrypted_as_string = decrypted.toString(CryptoJS.enc.Base64);
console.log("Decrypted message:", decrypted_as_string);
However when I insert CryptoJS.enc.Base64
in the toString()
argument, I get an error:
TypeError: e.clamp is not a function
It seems to be base 64 anyway, but I would rather specify that, than rely on some default. Is this not intended to work as I tried to make it work?