Symmetric Key Cryptography
Example № 2 of using XOR for symmetric encryption and decryption:
- The message "hi", in ASCII binary, is: 01101000 01101001. We create a random key of the same length:
00111010 10110010, and encrypt:
Data |
0 |
1 |
1 |
0 |
1 |
0 |
0 |
0 |
|
0 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
Key |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
0 |
|
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
Ciphertext |
0 |
1 |
0 |
1 |
0 |
0 |
1 |
0 |
|
1 |
1 |
0 |
1 |
1 |
0 |
1 |
1 |
the ciphertext won't necessarily be English letters. In our case, the ciphertext is: R█ (R and 'full block'.)
- Again, we use the same key to decrypt the ciphertext back to the message "hi":
Ciphertext |
0 |
1 |
0 |
1 |
0 |
0 |
1 |
0 |
|
1 |
1 |
0 |
1 |
1 |
0 |
1 |
1 |
Key |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
0 |
|
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
Data |
0 |
1 |
1 |
0 |
1 |
0 |
0 |
0 |
|
0 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |