Reading binary files and writing as text
I am a begginer C++ writer. I understand the basics but shy away from the structures and objects at the moment.
I am looking for the simplest way to read any binary file...(i understand all files are stored as binary) and i want to output that file and or work with it as "zeros and ones" in text.
I will eventually need to restore the file back to its original binary state and have it funcion with no alteration or loss.
Also is it possible to read ANY file and output it as text hex. I would assum so since its just another way of writing numbers.
Help me with this and you may soon see me on TV as a very rich man. Haha. Thanks.
Ecryption? (Secrect code?)
Nobody can tell you how to restore the file unless we know how you've "manipulated" it!!!
The most common method of simple encryption / decryption is to use bitwise "'exclusive or". You can look into "boolian logic" and "bitwise operations" if youi're not familiar with exclusive or. Exclusive or is a reversable operation... You XOR each character byte with a key byte. Now your characters are now "encoded". If you XOR again with the same key, they are decoded. Of course this isn't very secure because you only have to try all 256 possible keys (0-FF hex).
Now, if you want to try something really simple to get started, you could add one to each byte. This would change "A" to "B", "B" to "C", etc. Then subtract one to decode. Ummm... you might want to limit that to bytes that convert to ASCII characters.