You can provide your file with some structure before encryption and check if the structure exists after decryption. If there is no structure there, this is not your file.
For example, you can calculate the checksum and store it in the first bytes before the “payload” data block. Encrypt the checksum along with the rest of the file.
When you decrypt, load the contents of the payload and calculate its checksum again. Compare the result with the calculated result to see if the two match. If they do not match, this is not your file. If they match, there is a very good chance that this is your file.
This is not the only approach - the structure can be anything you want, from placing a special sequence of bytes in a certain place to using a certain strict format (for example, XML) for your content, and then checking this format after decryption.
[file] is encrypted using my own algorithm.
Be very careful with security through obscurity: coming up with an algorithm that is cryptographically secure is an extremely difficult task.
source share