Encryption is the process of converting a message from plain text into cipher text. The purpose of encryption is to make sure that data cannot be understood if intercepted. We often want to encrypt messages to make sure that only you and the intended recipient can access them.
Plain text is encrypted using a cipher and a key. A cipher is a set of instructions (an algorithm) for encrypting plain text. The key is additional information that is used by the algorithm. The same algorithm can be used with many different key values.
Decryption is the process of converting cipher text back into plain text. A key is also needed for the decryption process.
In a symmetric encryption scheme, the same key is used to encrypt and decrypt so the key must be shared between the sender and receiver.
An asymmetric scheme uses different keys (that are mathematically linked) to encrypt and decrypt. This means that the keys do not need to be shared.
The Caesar cipher is one of the earliest on record. It is credited to Julius Caesar, who used it to send secret messages to his armies. The Caesar cipher is sometimes called a shift cipher because the letters are effectively shifted by the number of positions specified by the value of the key.
The Caesar cipher shifts each letter of the plain text by an amount specified by the key. For example, if the key is 3, each letter is shifted three places to the right.
The Caesar cipher is easily cracked because there are only 25 possible keys. You can quickly reveal the message by trying each one in turn.
The Vernam cipher is, in theory, a perfect cipher. Instead of a single key, each plain text character is encrypted using its own key. This means that there is no way that the cipher text can be deciphered without the key.
The Vernam cipher is a substitution cipher where each plain text character is encrypted using its own key. This key — or key stream — is randomly generated or is taken from a one-time pad. The fact that each character of the message is encrypted using a different key prevents any useful information being revealed through a frequency analysis of the cipher text.
To apply the Vernam cipher, each bit of the binary character code for each letter of the plain text undergoes a XOR operation with the corresponding bit of each letter of the binary character code for the corresponding character from the key stream — this creates the cipher text.
Some additional rules need to be applied to achieve perfect security when using the Vernam cipher:
The characters in the key must be truly random
The key must be used once, and only once
There must be only two copies of the key (held by the sender and recipient) and the key must be secret to these parties