I am modifying a program that encrypts data in a cookie. There is a method to encrypt and one to decrypt the information. The original string being inserted is similar to: "A|S|99|3|True|Admin". I think it is being encrypted properlly, however, after it decrypts becomes an empty string.
I have never had to do anything like this and I am not sure what the problem can be. I know that if I skip the Encrypt and Decrypt functions, the system works fine. Anything I can check.
Private Shared Function Encrypt(ByVal s As String)
Try
Dim entropy As String = Environment.MachineName
Dim plainBytes() As Byte = Encoding.UTF8.GetBytes(s)
Dim entropyBytes() As Byte = Encoding.UTF8.GetBytes(entropy)
Dim encryptedbytes() As Byte = ProtectedData.Protect(plainBytes, entropyBytes, DataProtectionScope.CurrentUser)
...
Go to the complete details ...