Hey there.. i am trying to make an Encrypt and Decrypt method...
When i try to encrypt it goes fine.. but when i right after try to decrypt it i get an:
"Length of the data to decrypt is invalid" error...
the error occours when i try to run the code FlushFinalBlock();
here is my code:
public string Encrypt(string plainText)
{
UTF8Encoding utf8Encoder = new UTF8Encoding();
byte[] inputInBytes = utf8Encoder.GetBytes(plainText);
TripleDESCryptoServiceProvider tdesProvider = new TripleDESCryptoServiceProvider();
ICryptoTransform cryptoTransform = tdesProvider.CreateEncryptor(symKey, IVKey);
MemoryStream encryptedStream = new MemoryStream();
CryptoStream cryptStream = new CryptoStream(encryptedStream, cryptoTransform, CryptoStreamMode.Write);
cryptStream.Write(inputInBytes, 0, inputInBytes.Length);
...
Go to the complete details ...