XOR-Encryption

XOR is a bitwise operator and standard operation on bits and is called the 'eXclusive OR'.
XOR is true whenever an odd number of inputs is true.
In C-notation, XOR is written as ^ and in mathematical notation XOR is written as + with a circle around it.
Also note the following characteristics:

  • a XOR a = 0
  • a XOR b XOR b = a
This makes the encryption and decryption with one key (b) possible.
Let's take a look at the XOR-Encoding:
Let's assume we have a 3 letter key. We take the first letter of the plaintext and XOR it with the first letter of the key. Next, we take the second letter and XOR it with the second letter of the key. When we reach the fourth letter, we switch again to the first letter of the key. - We repeat the key.
An example:
"a" 01100001 XOR
"b" 01100010 =
00000011
We used the bitcode of ASCII 'a' as the plaintext and XORed it with the key ASCII 'b'.
Minding the fact that a XOR b XOR b = a, we can easily recover the plaintext:
"a xor b" 00000011 XOR
"b" 01100010 =
01100001 = ASCII "a"