This software is provided 'as-is', without any express or impliedwarranty. In no event will the authors be held liable for any damagesarising from the use of this software.

Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute itfreely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

===== Explanation ===== The XOR cipher is based uppon boolean logic XOR. The cipher uses the 2strings[plain & key] to safely encrypt the first(bit by bit).Table:---------------| A | B | XOR || 0 | 0 | 0 || 0 | 1 | 1 || 1 | 0 | 1 || 1 | 1 | 0 |--------------- If you have acces to at least two of the three [plain, key, ciphered]the remaining one is no longer protected. It is recommended to use a keyat most once since an attacker could start seeing patterns.--------------------------------------------------------------------------------*/#include <iostream>#include <fstream>#include <string>#include <limits.h>using namespace std;

O_O holy fucking sheep shit bat man. Who the fuck taught you to get the size of a file like that?!? Whoever it was, they should be fucking shot on site for fail.

use stat() to get the file size before you open it.

Also, i absolutely despise random access on files. I must recommend mmap() as an alternative. I'm at work atm so i can't post a super detailed post on anything, but code speaks louder then words imo. check this out i whooped to together typing at the speed of light in emacs.

This software is provided 'as-is', without any express or impliedwarranty. In no event will the authors be held liable for any damagesarising from the use of this software.

Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute itfreely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

===== Explanation ===== The XOR cipher is based uppon boolean logic XOR. The cipher uses the 2strings[plain & key] to safely encrypt the first(bit by bit).Table:---------------| A | B | XOR || 0 | 0 | 0 || 0 | 1 | 1 || 1 | 0 | 1 || 1 | 1 | 0 |--------------- If you have acces to at least two of the three [plain, key, ciphered]the remaining one is no longer protected. It is recommended to use a keyat most once since an attacker could start seeing patterns.--------------------------------------------------------------------------------*/#include <iostream>#include <iomanip>#include <fstream>#include <limits.h>#define MAX_LEN 128using namespace std;

This software is provided 'as-is', without any express or impliedwarranty. In no event will the authors be held liable for any damagesarising from the use of this software.

Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute itfreely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

===== Explanation ===== The XOR cipher is based uppon boolean logic XOR. The cipher uses the 2strings[plain & key] to safely encrypt the first(bit by bit).Table:---------------| A | B | XOR || 0 | 0 | 0 || 0 | 1 | 1 || 1 | 0 | 1 || 1 | 1 | 0 |--------------- It is recommended to use a key at most once since an attacker could startseeing patterns.(Frequency Analysis) It is also recommended that the length ofthe key is equal or more than the length of the plain.--------------------------------------------------------------------------------*/#include <iostream>#include <iomanip>#include <string.h>#include <fstream>#include <limits.h>#define MAX_LEN 512using namespace std;

I added a cout << toCrypt; Before and after the for loop of the cipher. It looks like it is how it handles char* that would be terminated by a space or other special characters?! Also, now if I try to cryptFile() Windows Complaints and exits the program.

So far I improved the cipher.(Which is more readable) and added a function to clear some main() space.

If you can't and don't write this in C, you have no business fiddling with C++.

Null Byte Poisoning? No.Again, you're working with bytes... not just strings ('strings' are a subset of bytes...). How do you expect to encrypt, say, an image or program instead of just the "abc123" test file?