Exclusive or, or exclusive disjunction, abbreviated as XOR, is a logical operator with the following truth table:
F | F | F |
F | T | T |
T | F | T |
T | T | F |
Symbols used to represent exclusive or including \oplus
) and \veebar
).
One way to understand the xor operator is “addition modulo 2”.
XOR in Cryptography
see also: XOR cipher and one-time pad
The XOR operation doesn’t leak information about the original plaintext (sometimes called “perfectly balanced”). In other words, knowing the result of an XOR operation doesn’t allow us to infer whether the original bit was more likely 0 or 1.”
It also has the property of being its own inverse:
These properties makes it useful in both encryption and decryption.