Progress pill
Mathematical Foundations of Cryptography 1

The XOR operation

All computer data is processed, stored, and sent across networks at the level of bits. Any cryptographic schemes that are applied to computer data also operate at the bit-level.
For instance, suppose that you have typed an e-mail into your e-mail application. Any encryption you apply does not occur on the ASCII characters of your e-mail directly. Instead, it is applied to the bit-representation of the letters and other symbols in your e-mail.
A key mathematical operation to understand for modern cryptography, besides the modulo operation, is that of the XOR operation, or “exclusive or” operation. This operation takes as inputs two bits and yields as output another bit. The XOR operation will simply be denoted as "XOR". It yields 0 if the two bits are the same and 1 if the two bits are different. You can see the four possibilities below. The symbol represents "XOR" :
To illustrate, suppose that you have a message (01111001) and a message (01011001). The XOR operation of these two messages can be seen below.
The process is straightforward. You first XOR the left-most bits of and . In this case that is . You then XOR the second pair of bits from the left. In this case that is . You continue this process until you have performed the XOR operation on the right-most bits.
It is easy to see that the XOR operation is commutative, namely that . In addition, the XOR operation is also associative. That is, .
An XOR operation on two strings of alternative lengths can have different interpretations, depending on the context. We will not concern ourselves here with any XOR operations on strings of different lengths.
An XOR operation is equivalent to the special case of performing a modulo operation on the addition of bits when the divisor is 2. You can see the equivalency in the following results:
Quiz
Quiz1/5
What does the XOR operation mean when applied between two bits?