Vernam cipher

The Vernam cipher uses a one time pad to encrypt messages. We XOR each character in the plaintext message with the corresponding character in the one-time pad to produce the ciphertext character.

For example, if the plaintext message is “HELLO” and the one-time pad is “XMCKL”, we can encrypt the message as follows:

PlaintextHELLO
PadXMCKL
Ciphertext?????

To encrypt each character, we can convert the letters to their ascii values and then XOR them:

So the ciphertext would be the characters corresponding to the ascii values 16, 8, 15, 7, and 3.

Decryption

Decrypting a message encrypted with the Vernam cipher is exactly the same process as encrypting it! We XOR the ciphertext character with the corresponding character in the one-time pad, which gives us the ascii value of the original plaintext character.

For example, if we have the ciphertext characters corresponding to the ascii values 16, 8, 15, 7, and 3, and we know the one-time pad is “XMCKL”, we can decrypt it as follows:

So we would recover the original plaintext message “HELLO”.

Security

IF we use it with a truly random one-time pad, and we never reuse the same pad for multiple messages, then the Vernam cipher is considered to be unbreakable (assuming nobody else gets access to the one-time pad). This is because each character in the plaintext message is encrypted with a different key, so there is no way to analyse patterns in the ciphertext to try to crack the key.

Issues

The main issues really come from the fact that it uses a one-time pad, which can be difficult to distribute securely. How do you share the OTP with only the intended recipient without it being intercepted by an attacker?