I\'m trying to figure out how to encrypt / decrypt a string in VB.Net.
I followed the example given here and wrote the following code (below). There\'s a text box,
The issue I spotted is on this line in your encryption code:
Me.TextBox1.Text = Me.enc.GetString(ms.ToArray())
The problem is that this assumes your byte array already is a UTF-8 string, just carved up as a byte array, when in fact it should be random bytes and likely includes unprintable characters. It's not valid utf-8 data. What you want to do instead is base-64 encode that byte array using the Convert.ToBase64String() function.
Then, your decryption needs to correctly convert that base 64 string back to a byte array, using the Convert.FromBase64String() method.