Decryption Key value not match?

The same key (Key) and initialization vector (IV) used to encrypt the file must be used to decrypt it. I can't fully check this code currently so there may be one or two small problems but give it a try and let me know if it works, hopefully you get the idea.

The same key (Key) and initialization vector (IV) used to encrypt the file must be used to decrypt it. I can't fully check this code currently so there may be one or two small problems but give it a try and let me know if it works, hopefully you get the idea: public static string DecryptTextFromMemory(byte Data, byte Key, byte IV) { try { // Create a new MemoryStream using the passed // array of encrypted data. MemoryStream msDecrypt = new MemoryStream(); // Create a CryptoStream using the MemoryStream // and the passed key and initialization vector (IV).

CryptoStream csDecrypt = new CryptoStream(msDecrypt, new TripleDESCryptoServiceProvider(). CreateDecryptor(Key, IV), CryptoStreamMode. Write); csDecrypt.

Write(Data, 0, Data. Length); csDecrypt.FlushFinalBlock(); msDecrypt. Position = 0; // Create buffer to hold the decrypted data.

Byte fromEncrypt = new bytemsDecrypt. Length; // Read the decrypted data out of the crypto stream // and place it into the temporary buffer. MsDecrypt.

Read(fromEncrypt, 0, msDecrypt.ToArray(). Length); csDecrypt.Close(); //Convert the buffer into a string and return it. Return new UTF8Encoding().

GetString(fromEncrypt); } catch (CryptographicException e) { MessageBox. Show("A Cryptographic error occurred: {0}", e. Message); return null; } }.

There is a full example for how to encrypt and decrypt using a MemoryStream on msdn here, scroll down to the middle of this webpage: msdn.microsoft. Com/en-us/library/… – Peter McGrattan May 6 '10 at 11:18 Sure Exactly we are following this example.. but when you Encrypt and decrypt at the same time suppose this console application, this is working properly. But we r using first registration time Encrypt Data and when we adduser at that time we call decrypt method so it would be quit defferent bytes of data and key as well IV so this is the main problem.. tell me what to do.. thanks.

– Jitendra Jadav May 6 '10 at 11:41 Of course the data bytes will be different but the (Key) and (IV) MUST be the same as that used to encrypt. So always use the same (Key) and (IV) when you encrypt and decrypt, store them in a static class that is available everywhere in your app, I can't be any clearer than that. – Peter McGrattan May 6 '10 at 20:41.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions