## Cryptage XOR

In cryptography, the simple XOR cipher is a simple encryption algorithm that operates according to the principles:

A XOR 0 = A,

A XOR A = 0,

(A XOR B) XOR C = A XOR (B XOR C),

(B XOR A) XOR A = B XOR 0 = B,

where XOR denotes the exclusive disjunction (XOR) operation. 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 key will remove the cipher.

For example, the string 01010111 01101001 01101011 01101001 in 8-bit ASCII can be encrypted with the key 11110011 as follows:

01010111 01101001 01101011 01101001

XOR

11110011 11110011 11110011 11110011

=

10100100 10011010 10011000 10011010

And conversely, for decryption:

10100100 10011010 10011000 10011010

XOR

11110011 11110011 11110011 11110011

=

01010111 01101001 01101011 01101001

The XOR operator is extremely common as a component in more complex ciphers. By itself, using a constant repeating key, a simple XOR cipher can trivially be broken using frequency analysis.

If the content of any message can be guessed or otherwise known then the key can be revealed. Its primary merit is that it is simple to implement, and that the XOR operation is computationally inexpensive.

A simple repeating XOR cipher is therefore sometimes used for hiding information in cases where no particular security is required.

## 0 Replie(s)