T
Tyler
I have read that a similar problem to the one I describe below has been
discussed on the microsoft.public.dotnet.security newsgroup, but I was
unable to see a solution to the problem with which I am struggling. I am
hoping that someone reading here will be able to assist me.
As far as I can tell, I'm doing exactly what the article at
http://www.dotnetthis.com/Articles/Crypto.htm does, but I keep getting this
exception. If someone could assist or point me to a good, relevant article,
that would be great.
Here's a snippet of code that demonstrates my problem:
-------------------------------------------------------------------------
// Input - actually obtained from output of previous encryption
byte [] atvyData = new byte [8] {0xE4, 0x83, 0x16, 0xD4, 0x89, 0x47, 0xAE,
0x68};
// Encryption key and initialization vector to use
byte [] atvyKey = new byte [8] {0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA,
0xFA};
byte [] atvyIV = new byte [8] {0, 0, 0, 0, 0, 0, 0, 0};
// Decrypt
MemoryStream tvOutput = new MemoryStream();
DESCryptoServiceProvider tvDESAlg = new DESCryptoServiceProvider();
CryptoStream tvCryptStream = new CryptoStream(tvOutput,
tvDESAlg.CreateDecryptor(atvyKey, atvyIV), CryptoStreamMode.Write);
tvCryptStream.Write(atvyData, 0, 8);
tvCryptStream.FlushFinalBlock();
byte [] atvyResult = tvOutput.ToArray();
-------------------------------------------------------------------------
Every time I execute the 'tvCryptStream.FlushFinalBlock()' I get the 'Bad
Data' exception - why? I have tried numerous tweaks and variations to the
code above and have been unable to get rid of the exception.
Any help would be greatly appreciated!
Thanks, Tyler
discussed on the microsoft.public.dotnet.security newsgroup, but I was
unable to see a solution to the problem with which I am struggling. I am
hoping that someone reading here will be able to assist me.
As far as I can tell, I'm doing exactly what the article at
http://www.dotnetthis.com/Articles/Crypto.htm does, but I keep getting this
exception. If someone could assist or point me to a good, relevant article,
that would be great.
Here's a snippet of code that demonstrates my problem:
-------------------------------------------------------------------------
// Input - actually obtained from output of previous encryption
byte [] atvyData = new byte [8] {0xE4, 0x83, 0x16, 0xD4, 0x89, 0x47, 0xAE,
0x68};
// Encryption key and initialization vector to use
byte [] atvyKey = new byte [8] {0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA,
0xFA};
byte [] atvyIV = new byte [8] {0, 0, 0, 0, 0, 0, 0, 0};
// Decrypt
MemoryStream tvOutput = new MemoryStream();
DESCryptoServiceProvider tvDESAlg = new DESCryptoServiceProvider();
CryptoStream tvCryptStream = new CryptoStream(tvOutput,
tvDESAlg.CreateDecryptor(atvyKey, atvyIV), CryptoStreamMode.Write);
tvCryptStream.Write(atvyData, 0, 8);
tvCryptStream.FlushFinalBlock();
byte [] atvyResult = tvOutput.ToArray();
-------------------------------------------------------------------------
Every time I execute the 'tvCryptStream.FlushFinalBlock()' I get the 'Bad
Data' exception - why? I have tried numerous tweaks and variations to the
code above and have been unable to get rid of the exception.
Any help would be greatly appreciated!
Thanks, Tyler