I have UTF-8 text delimited with Chr(13) (it splits fine into an array on Chr(13)). If I encrypt the text with AES Encrypt, then Decrypt all with the same key and IV as it should be done the decrypted text comes back with the special encode of “�” in place of Chr(13). If I Base64Encode it after encryption and decode before decryption to protect it from any OS permutation it comes back the same way. No combinations of encodings work (replace line endings, EndOfLine.MacOs, CRLF, etc.) instead of Chr(13). This text is in a TextArea and going back into the TextArea. So I start off with text made up of several delimited sentences and end up with one long string with � interspersed where the Chr(13) was. What am I doing wrong here? I would think encryption/decryption would properly handle this. Thanks!
Check the encoding of the string. Probably during some binary operation you changed it or lost it (like UTF-8 becoming Nil). Set it back to the appropriated one. You probably need to adjust it right after the decryption.
Thanks Rick, I thought I had checked that, ended up making some changes.
I set text = text.encoding(encodings.utf8) before encryption and the same to the return value from my decrypt method. Worked perfect!
2 Likes