RU EN ES 中文

Vernam Cipher

The only theoretically unbreakable cipher.
Bitwise XOR encryption, the one-time pad,
and why it remains the gold standard of secrecy.

Why do we need this?

Every classical cipher (before the rise of modern cryptographic systems) has a weakness: it relies on deterministic algorithms and repeating keys. Sooner or later, statistical analysis (the Kasiski method, the index of coincidence) reveals the message.

An attempt to fundamentally overcome this weakness was the Vernam cipher, where encryption is built on a bitwise combination of the message with a key sequence. But what really matters isn't the transformation itself — it's the properties of the key. Perfect, or absolute, secrecy is achieved only in a special case of this scheme — the one-time pad, where the key is truly random, at least as long as the message, made of independent elements, kept secret, and used only once. If all these conditions hold, it becomes impossible to determine the original message from the ciphertext: to an attacker, every possible plaintext looks equally likely.

In 1949, Claude Shannon mathematically proved the absolute security
of the one-time pad — an implementation of the Vernam cipher with an ideal key. This approach is presumably used in critical military or diplomatic communications, where absolute, provable security is required
(including resistance to quantum computers).

How does it work?

At the heart of the cipher is a simple yet brilliant operation: exclusive OR (XOR). The message and the key are represented as bit strings, and each bit of the message is combined with the corresponding bit of the key according to the XOR rule.

Message bit (P)Key bit (K)Ciphertext (C = P ⊕ K)
000
011
101
110
1

Converting to bits

The message (text) is converted into a binary sequence using an encoding: the Baudot code (5 bits per character) was the standard at the time the Vernam cipher was created.

2

Generating the ideal key

A random bit string is generated, the same length as the message. Each bit is truly random (0 or 1 with probability ½). The key is known only to the sender and the receiver and is used only once.

3

Encryption (XOR)

C = P ⊕ K — bitwise addition modulo 2. The resulting ciphertext can be sent over an open channel: without the key, it looks like random noise.

Example: message 101 ⊕ key 011 = ciphertext 110.

4

Decryption

Bob, holding the same key, XORs the ciphertext with the key: P = C ⊕ K. Thanks to the property (P ⊕ K) ⊕ K = P, the original message is recovered without any loss.

The mathematics of the Vernam cipher
🔐 Encryption
C = P ⊕ K
Example (ASCII):
Message H = 72 = 01001000
Key (first 8 bits) = 10110101
C = 11111101 = 253 (non-printable character)
🔓 Decryption
P = C ⊕ K
Example:
C = 11111101 ⊕ K = 10110101
= 01001000 → H
Why is this unbreakable?
For a cryptanalyst, the ciphertext contains no information at all about the original message. Any possible plaintext can be obtained by picking a suitable key. Since every key is equally likely, an attacker cannot tell the real message from a false one.
Key = Message length · Randomness · Single use
* In the interactive game you can choose an encoding, generate a random key, and watch the XOR operation step by step or instantly.
Key takeaway: Perfect secrecy comes at the cost of perfectly secret keys. In practice, the challenge lies in generating truly random keys and delivering them securely. That's why the one-time pad is reserved for especially critical communications, while everyday cryptography relies on practical compromise algorithms (Kuznyechik, Magma, AES, ChaCha20).

And now — the real magic

What will you actually do in the interactive simulation?

The game fully visualizes the principle of perfect secrecy: you'll see for yourself that without the key the ciphertext looks like random noise, while with the key it instantly turns back into the original message.

For the curious

Historical background

In 1917, Gilbert Vernam, an AT&T engineer, patented a cipher that XORed a telegraph tape (the 5-bit Baudot code) with a punched key tape. Later, Joseph Mauborgne proposed using random keys, and in 1949 Claude Shannon published "Communication Theory of Secrecy Systems," in which he rigorously proved that the one-time pad is a perfectly secure cipher.

Why isn't it used everywhere?

Three practical problems:

  • Key length: the key must be at least as long as the message. Transmitting large volumes of data requires enormous keys.
  • Key distribution: the key has to reach the recipient over a secure channel.
  • Single use: reusing a key destroys security — two ciphertexts can be analyzed together (C1⊕C2 = P1⊕P2).

Topics for further study

Quantum key distribution (QKD)

How quantum physics solves the problem of securely transmitting keys for the one-time pad.

True random number generators

Hardware RNGs based on thermal noise, radioactive decay, or quantum effects.

Key-reuse attacks

How a cryptanalyst recovers messages from ciphertext alone if a key was used twice (C1⊕C2 = P1⊕P2).

Modern stream ciphers

How Vernam's principles live on in Salsa20, ChaCha20, and AES-CTR (generating a pseudo-random keystream).

Shannon's theorem

A rigorous mathematical proof of perfect secrecy, showing that the key's entropy must be at least as large as the message's entropy: H(K) ≥ H(M).

The key-distribution problem

Why securely delivering long random keys remains the main practical limitation of the one-time pad.

Practical uses and mentions

The Vernam cipher is mentioned in:

  • The use of one-time cipher materials in Soviet intelligence.
    Source: Christopher Andrew, Vasili Mitrokhin. The Mitrokhin Archive
  • The history of ciphers and the development of one-time schemes.
    Source: A. A. Babash, G. P. Shankin. History of Cryptography
  • The practical use of one-time pads in intelligence and diplomacy.
    Source: D. Kahn. The Codebreakers
  • The compromise of Soviet one-time keys due to their reuse.
    Source: NSA. VENONA

Now that you understand the mathematical foundation, it's the perfect time to see the Vernam cipher in action — bit by bit, visually, and interactively!

In the simulation you can choose an encoding, generate a random key, encrypt a message step by step, and watch the animated data transfer.