Vernam cipher is a symmetrical stream cipher in which the plaintext is combined with a random or pseudorandom stream of data of the same length, to generate the ciphertext, using XOR function.

To put is simply, vernam cipher is based on the principle that each plaintext letter from a message is combined with one character from a key stream.

- Read: Stream cipher.

The random key stream used needs to be completely random so that the resulting ciphertext bears no relation to the original plaintext.

- Read: What is ciphertext.

For this reason, vernam ciper works in similar way to the unbreakable One-time pad (OTP).

When you examine this cipher closely, it is actually a particular case of Vigenere cipher where the key is as long as the text, which makes cryptanalysis attacks useless.

A brief history of Vernam cipher:

It was invented by the American scientist, Gilbert Vernam in 1917 while working at AT&T.

It was used with teleprinters and 5-level punched tape, the system was also known as one-time tape (OTT).

Vernam proposed a bit-wise exclusive or of the message stream with truely random zero-one stream which was shared by sender and recepient.

Note, the key should never be used more than once, since this introduces a weakness than an attacker can exploit.

If the key is genereated truly randomly, this cipher is unbreakable without the explicit knowledge of the key.

## Vernam Cipher

In this guide I will be discussing the following:

- How to solve vernam cipher.

### How to solve vernam cipher

#### How to encrypt using Vernam cipher

This is the same as Vigenere encryption method but uses a key at least as long as the plaintext.

Here is an example:

**Plaintext**: Kifanga.

To encrypt KIFANGA, I need a key of at least 5 letters KEYWORD or PASSWORD.

If the key is not long enough, it can be repeated, same as in the vigenere cipher, but this is not recommended as it presents security loopholes.

Here is a random key generator tool to use.

**Key**: verdict.

Here is a tool to decrypt/encrypt with vernam.

#### How to decrypt Vernam cipher

Decryption process is also identical to Vigenere decryption method.

#### How to recognize Vernam ciphertext

Message encoded with Vernam has an index of coincidence close to a random text.

#### How to decipher Vernam without key

If the key length is as long as the text length, then no cryptanalysis method can crack Vernam.