When i attempt to decrypto my string i get the following error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Security.Cryptography.CryptographicException: Length of the data to decrypt is invalid.
at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
The code i try is:
System.IO.MemoryStream ms = new System.IO.MemoryStream(encryptedcryptData.Bytes, 0, encryptedcryptData.Bytes.Length);
byte[] b = new byte[encryptedcryptData.Bytes.Length - 1 + 1];
ValidateKeyAndIv(false);
CryptoStream cs = new CryptoStream(ms, _crypto.CreateDecryptor(), CryptoStreamMode.Read);
try
{
cs.Read(b, 0, encryptedcryptData.Bytes.Length - 1);
}
catch (CryptographicException ex)
{
throw new CryptographicException("Unable to decrypt cryptData. The provided key may be invalid.", ex);
}
finally
{
cs.Close();
}
return new cryptData(b);
How can i get rid of this error. Thank sin advance...