Symmetric Key Cryptography
Example № 1 of using XOR for symmetric encryption and decryption:
- To encrypt the data 1011 using some randomly generated key 1101, apply the XOR to each pair of bits as follows:
Data |
1 |
0 |
1 |
1 |
Key |
1 |
1 |
0 |
1 |
Ciphertext |
0 |
1 |
1 |
0 |
because, according to the truth table, we have 1 ⊕ 1 = 0 for the leftmost pair of bits, 0 ⊕ 1 = 1, for the 2nd pair, 1 ⊕ 0 = 1 for the 3rd pair, and 1 ⊕ 1 = 0 for the rightmost pair. The ciphertext is, therefore, 0110.
- You will use the same key 1101 to decrypt the ciphertext 0110 back to your plaintext data 1011! Here's why:
Ciphertext |
0 |
1 |
1 |
0 |
Key |
1 |
1 |
0 |
1 |
Data |
1 |
0 |
1 |
1 |