XOR Cipher
Combine each byte of your text with a key using exclusive or.
How it works
XOR, short for exclusive or, compares two bits. The result is 1 if the bits differ and 0 if they are the same. Its useful property is that doing it twice with the same value undoes it: (A XOR K) XOR K gives back A. So one operation both encrypts and decrypts.
This tool turns your text and key into bytes, then XORs each byte of the text with the next byte of the key, starting the key again when it runs out. The result is raw bytes that are often not printable, so it is shown in hex.
XOR is the workhorse inside almost all modern encryption, where it combines data with a long stream of unpredictable bits. Used alone with a short repeating key, as here, it is weak. The key length can be found from repeating patterns, and each key byte then falls to simple frequency counting. If the key is random, as long as the message and never reused, it becomes a one-time pad.
Worked example
The letter A is 01000001. The key letter a is 01100001. They differ in one bit, so the result is 00100000, which is 20 in hex.
XOR truth table
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Common questions
Why is the output in hex?
XOR can produce any byte value, including ones with no visible character. Hex shows every byte safely.
Is XOR encryption secure?
Not with a short repeating key. It is fine for puzzles and for hiding text from casual view, nothing more.