I've been messing around with XOR encryption, one-time pads etc. and it's working fine with reading simple one line text files. The problem is with multi line texts. After encrypting and then decrypting it again, it would only output the first n characters. It seems to be unreliable every time I encrypt and decrypt.
Don't cry because it's over, smile because it happened.
I'm selfish, impatient and a little insecure. I make mistakes, I am out of control and at times hard to handle. But if you can't handle me at my worst, then you sure as hell don't deserve me at my best.
After fixing all that, don't have your problem.
Wonder if there may be an issue in how windows handle the non-graphic characters in an std::string. Set a breakpoint on `decryptFile()' and see if you are reading all the data correctly.
Sample code to read from a file opened in binary mode:
1 2 3 4 5 6 7 8 9 10 11 12 13
ifstream in("file", ifstream::binary)
// should add a check to see if file is open
in.seekg(0, in.end);
size_t len = (size_t)in.tellg();
in.seekg(0);
char* data = newchar[len];
in.read(data, len);
// add xor encryption function here
// save the encrypted file
- Start with a simple algorithm first, then slowly add some "salt" to make it more advanced.