7.3 The XOR Operation
The XOR operation is a binary logical operation that is applied to two bits. Table 7.6 shows how the operation works.
|
⊕ |
0 |
1 |
|
0 |
0 |
1 |
|
1 |
1 |
0 |
Table 7.6 How the XOR Operation Works
The result is 1 if exactly one of the two bits is 1; otherwise, the result is 0. This operation is also referred to as exclusive OR. This is because, in contrast to the OR operation (see Table 7.7), the result is not 1 if both bits are 1.
|
v |
0 |
1 |
|
0 |
0 |
1 |
|
1 |
1 |
1 |
Table 7.7 How the OR Operation Works
The XOR operation has mathematical properties that are particularly useful in cryptography. These are listed in Table 7.8.
|
Property |
Formal Representation |
|---|---|
|
Involutivity |
A ⊕ B ⊕ B ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access