My recent turn-on is using BinaryFormatter instead of some database product. I have an idea to write simple 64bit number into hardware dongle, and encrypt my files with it – via simple XOR operation. Just so it can’t be readable at some other end. Do I derive from Stream, or what?
I know I can simply put that number into the file and check against it on reading, but… I’ll feel better if it’s XORed all the way.
I’m not going to comment on XOR encryption, that’s too silly. Lets focus on practical guidance to implement your custom stream. You should derive it from Stream so it has a familiar interface to the user. Right-click “Stream”, Implement Abstract Class. You can leave most of the NotImplementedException throws in place, streams are commonly crippled like this. Add a private FileStream member, it will do the hard work. Then add: