Hi,
reading the documentation I wrote few lines in order to try to decrypt something.
Unfortunately I always get back an exception : "System.Security.Cryptography.CryptographicExcepti on' occurred in mscorlib.dll" - Additional information: Bad Data. when "FlushFinalBlock" is called.
Someone told me that could be an issue related the conversion between strings and bytes, but in my sample I'm working with bytes only...why?
.....
Dim td As TripleDES = New TripleDES
Dim cif() As Byte = {248, 67, 20, 198, 184, 91, 211, 176}
Dim key() As Byte = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
Dim iv() As Byte = {65, 110, 68, 26, 69, 178, 200, 219}
' As before we must provide the encryption/decryption key along with
' the init vector.
Dim tdesProvider As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider
Dim cryptoTransform As ICryptoTransform = tdesProvider.CreateDecryptor(key, iv)
' Provide a memory stream to decrypt information into
Dim decryptedStream As MemoryStream = New MemoryStream
Dim cryptStream As CryptoStream = New CryptoStream(decryptedStream, cryptoTransform, CryptoStreamMode.Write)
cryptStream.Write(cif, 0, cif.Length)
cryptStream.FlushFinalBlock()
Thank you very much,
Luca
--------------------------------
From: luca minelli
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>GpXn+IbltU+CH9XlBGWW8A==</Id>