Question
What is the XOR operation and why is it fundamental to symmetric cryptography?
Answer
XOR (exclusive OR) outputs 1 when the two input bits differ, and 0 when they are the same.
* The same XOR with the key both encrypts and decrypts — $(A \oplus B) \oplus B = A$. *
Truth table:
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Why it matters for cryptography:
- XOR is its own inverse: $(A \oplus B) \oplus B = A$ — this means the same operation encrypts and decrypts
- It's extremely fast in hardware (single gate)
- It perfectly mixes bits without losing information (bijective for a fixed key)
Tip: Think of XOR as a "toggle switch" — applying the same key toggles between plaintext and ciphertext.
Go deeper:
XOR cipher (Wikipedia) — how XOR builds the simplest symmetric cipher.
Note saved — thanks!
Question
How do you perform XOR on binary numbers? Calculate: $1010\,0111 \oplus 0011\,1100$
Answer
Apply XOR bit by bit — where bits differ you get 1, where they match you get 0. Result: $1001\,1011$.
Step by step:
$$\begin{array}{r} 1010\,0111 \\ \oplus\; 0011\,1100 \\ \hline 1001\,1011 \end{array}$$
Each column is independent — just compare the two bits:
- $1 \oplus 0 = 1$, $0 \oplus 0 = 0$, $1 \oplus 1 = 0$, $0 \oplus 1 = 1$, $0 \oplus 1 = 1$, $1 \oplus 1 = 0$, $1 \oplus 0 = 1$, $1 \oplus 0 = 1$
Tip: "Same = 0, Different = 1" — that's all you need to remember for XOR.
Note saved — thanks!