XOR cipher

In cryptography, the simple XOR cipher is a type of additive cipher,[1] an encryption algorithm that operates according to the principles:

A 0 = A,
A A = 0,
A B = B A,
(A B) C = A (B C),
(B A) A = B 0 = B,

For example where denotes the exclusive disjunction (XOR) operation.[2] This operation is sometimes called modulus 2 addition (or subtraction, which is identical).[3] With this logic, a string of text can be encrypted by applying the bitwise XOR operator to every character using a given key. To decrypt the output, merely reapplying the XOR function with the key will remove the cipher.

  1. ^ Tutte 1998, p. 3
  2. ^ Lewin 2012, pp. 14–19.
  3. ^ Churchhouse 2002, p. 11