PHP mcrypt_decrypt - can I determine if data is decrypted with the right key?
问题 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