I create my file using File.WriteAllBytes()
. Byte[] that is passed to File.WriteAllBytes()
is encrypted by algorithm of my own. You need password that was used when file was encrypted (user of the program knows the password) to decrypt it. But when some file is opened by my program using File.ReadAllBytes()
there are 3 situations:
- File that is being opened is my program's file and user knows the password to open it.
- File that is being opened is my program's file but user doesn't know the password to open it.
- File that is being opened is not my program's file.
First one is easy to handle. 2nd and 3rd are same for my program because my program doesn't know the difference between encrypted byte[] and byte[] of some random file.
How do I differ these situations? I was thinking of adding some sequence of bytes to the end or beginning of byte[] before passing it to File.WriteAllBytes()
. Is that safe? How do modern programs differ their files from other files?