Emailing encrypted text.

I copy text from Taxtarea and then encrypt it using rc4v6, I then copy it to the clipboard and shut down the program and then start it again I then paste the text back to a variable and decrypt it and this works fine.
If I paste to an email and send it to myself then copy to clipboard and then paste to variable it turns out as garbage after decrypting.

Anybody any idea why…?

Hi @Ian Cartwright, may it be related with some kind of encoding conversion?

Could you paste a sample here, both directly from app, and the same from the email?

Email clients will most certainly try to interpret the encrypted binary as text (or auto-magically add linebreaks), which will mess things up…

If it needs to be binary, then consider attaching as a file (message.encrypted_data).

If it needs to be plain text… then consider:

  • (Encode/Decode)Base64
  • transfer the encrypted binary data as ‘Hex String’

Please except my apologies as seems I made a mistake and copying to and from the clipboard does not work.

the text to encrypt is:
“The cow jumped over the moon” Password is “fredfred”
the encrypted text that will decrypt if help in variable is =
The text after sending to the clipboard and pasting back and decrypting is =
“z(ࠖ a9$
[ WVu”

Any further info just ask.
Double checked code but cannot see a problem.

It looks like you are working with binary data as if it is text, and that won’t work. Use @Jürg Otter 's suggestion and encode the data first, then decode before processing.

sorry but don’t get that not sure what he means.
example would be nice…Please

After you get the result of your encryption, encode it. Before decrypting, decode it. Example:

dim s as string = Encrypt( data )
s = EncodeBase64( s )
// Store or copy s

s = MyPastedData
s = DecodeBase64( s )
dim data as string = Decrypt( s )

Thank you very much will give it a try.



It works fine for both clipboard too and from
and also works with email.

once again thank you very much for your help and your time.


Thanks for the example - I didn’t feel comfortable writing one on the Phone while travelling by train when I posted the suggestions :slight_smile:

@Ian Cartwright: The ‘Hex String’ suggestion would be the same approach. Instead of EncodeBase64 and DecodeBase64, you would use: EncodeHex and DecodeHex.

Same goal: Convert the “encrypted binary data” (a “bag of bytes”) in some form of “plain text” that can be processed further without much hassle (Encodings, Encodings-Conversions, Auto-Text-Formatting, or whatever else might be going on in an Email client and when sending the message through various mail servers).

Just thought I would let you know that both methods work equaly as well.

Thank You.

The differences: Base64 will result in a smaller string that can be broken up by lines without additional processing, but is case-sensitive. Hex is longer, you would have to manually break it up into lines if desired, but is case-insensitive.

Whichever works for you.

Base64 increases the String length by ?, while Hex doubles the size.