Symmetric Key Cryptography
Conclusions from the two examples:
- We XORed data with the key to get the ciphertext, and then XORed the ciphertext with the key to get the data. Because the same key was used for both encryption and decryption, XOR is a symmetric cipher.
- Messages in English can be encoded in (= converted to) the ASCII equivalencies, and then applied with the XOR cipher. That is, we can use the XOR cipher not only on numbers but also on letters, symbols, etc. For messages in other languages, you can use the Unicode table instead.
For the XOR cipher to be considered secure:
- The size of the key must equal to or larger than the size of the data/message,
- The key must be generated randomly (such as by using a reliable pseudo-random number generator,)
- The key mustn't be reused for future encryptions of the same data, and, obviously,
- The key must be kept secret.