I'm working on a php script and are using mcrypt to encrypt/decrypt arbitrary data.
When I decrypt encrypted data, using another key (e.g. I typed in the wrong password), the output won't be correctly decrypted of course.
If the wrong key has been used I would like to display an error message, but I'm thinking it's quite hard to validate the output string as correct "plaintext" (since the chars in the encoded data are also valid as input data).
Is there any way to get around this?
As I was writing this question, I got an idea :)
Could I possibly prefix the input data with a static "control" string and use this for validation when I decrypt?