So just what is so special about XOR? First, suppose that
we want to perform a cryptographic substitution of a
plain text bit. We'd like to prevent an attacker from making
any prediction (even statistical) about what the transformed
value of our plain text bit will be. With XOR, a plain text
0 bit might become either a cipher text 1 or 0,
depending on whether a 0 or 1 is used as the "encryption
bit" (the second bit in the domain pair). Likewise for
a plain text 1. Complete lack of predictability of the
transformation is ideal for cryptography (unless you have access to the
encryption bit).
The other crucial feature of XOR is that it is lossless.
In fact, XOR is directly reversible. That is,
if we have Cb = Pb XOR Kb
, then we automatically
know that Pb = Cb XOR Kb
. That is, a
reapplication of XOR to the result of a first XOR operation will
return to original (plain text) bit if (and only if) the same
encryption bit is used both times. Contrast this with the
behavior of a different Boolean operation:
AND(1, 1) --> 1
AND(1, 0) --> 0
AND(0, 1) --> 0
AND(0, 0) --> 0
In performing an AND, we lose information. Suppose
that we know 0 = Pb AND Kb
. It is true enough
that we cannot reconstruct Pb without the encryption bit.
However, if Kb happens to be 0, we cannot reconstruct Pb
even with the encryption bit! We have simply lost any way
of getting Pb back.