I'm using Rijndael to encrypt/decrypt some sensitive images that will be used on some documents. I'm trying to be absolutely sure that the password provided works and that, by some quirk of fate, an incorrect password will result in a corrupted image that ends up on the document. If I don't catch it before this point, lots of documents and money will end up getting thrown away.
My current plan is to create a MD5 checksum to store along with the images. If the decrypted stream's MD5 is different than the original stream, I know the password was incorrect. However, in testing, it appears that an incorrect password results in an exception being thrown.
Is that true 100% of the time? Can I do away with the checksum and just catch an exception?