Rijndael image encryption problem

Apr 1 2011 9:08 PM
Hi i have a problem with Rijndael encryption (I've uploaded the source code). Basically i'm trying to convert an image into byte[] data, run Rijndael encryption on it based on a given password. Then i need to be able to convert that Byte[] data back into a bmp. This is where the problem seems to occur. The line:

tempImage = Image.FromStream(ms, true);

always throws the exception "invalid paramater" meaning that it can't read the byte[] data and convert it into a bmp image. If i take out the Rijndael encryption, there is no problem but for some reason, when i do use it, it seems to give me back an invalid byte[] representation for a bmp?! I've been trying to work out what's going on here for a while and it's getting really frustrating. I'd appreciate any help that can be given.

Also, you may notice that i've used a message box to show me information about the byte data before and after encryption. I did notice that the byte[] data afterwards was 10 larger than before encryption. I don't know why or what this means but it seems to occur first at the line:

byte[] encryptedData = ms2.ToArray();


Thanks in advance :)

Answers (3)