Functional XOR Encryption

Aug 23, 2011 at 7:55pm
Hi Everyone,

So I've been "inspired" by some posts recently to try my hand at breaking the encryption methods, but before I do that I need a functional way to implement it. I've decided to start off with XOR encryption but that means I need a way to implement XOR that is reversable and I'm stuck.

Here's my issue, say you're using what should be a simple key word cipher. Well when the letter of the key word is the same as the letter in the word you're trying to encrypt then that logically works out to be NULL which isn't written to the output file, or even to memory from what I can tell. Even worse landing on any one of the command characters (backspace, start of file, end of file, etc.) just end up destroying the whole thing. But any attempt to filter these characters out weakens the encryption to the point of it being completley useless.

I believe I've "thought myself into a corner" and I can't get out of this mental loop that ends up leading no where. Do any of you know if this is just a flaw in using XOR for encryption? Is there a common way around these issues? Should I just skip XOR and move on to another form?

I've already cracked Ceasar shifts and Vigenère ciphers up to a preset amount of index's so if I should skip XOR then where would I go next? I'm having way too much fun with this to just quit right now.
Aug 23, 2011 at 8:03pm
Just use write() instead of <<. It's not text you're writing now.
Aug 23, 2011 at 8:15pm
I still hit the issue with the command characters. I could try to work around the NULL but not backspace or end of file.

EDIT: If I've wasted a week on this it would suck but I'm ready to except it. You don't need to spare my feelings after all I knew there had to be a reason that this wasn't used but I didn't put any effort into trying to figure out why so it would be my fault.

I'm giving it one more shot, I'll convert the the char's into integers so that the encrypted character gets recorded as a number thus eliminating the issues with command characters. It's logical to me to think that the recipient would know to convert them to chars in order to read it and I don't think this would be any weaker, it certainly isn't any weaker then crippling XOR into a shiney Vigenère cipher.
Last edited on Aug 23, 2011 at 8:31pm
Aug 23, 2011 at 9:41pm
I don't see why you are having trouble with specific byte values. Are you reading/writing data as text? That would be an incorrect approach, at least for writing the encrypted data. Encrypted data is binary. In binary mode, you should by able to write any byte value, including zero.
Aug 23, 2011 at 10:04pm
THAT'S WHAT I NEEDED! I had the output file opened in truncate mode so that I wouldn't have to keep deleting it. I forgot all about binary mode as an option! THANK YOU!

Wow, all it takes sometimes is someone reminding you of basics. You guys are awsome thanks again!
Topic archived. No new replies allowed.