The only theoretically unbreakable cipher. Bitwise XOR encryption, the one-time pad, and why it remains the gold standard of secrecy.
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).
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) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
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.
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.
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.
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.
H = 72 = 010010001011010111111101 = 253 (non-printable character)11111101 ⊕ K = 1011010101001000 → HWhat 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.
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.
Three practical problems:
How quantum physics solves the problem of securely transmitting keys for the one-time pad.
Hardware RNGs based on thermal noise, radioactive decay, or quantum effects.
How a cryptanalyst recovers messages from ciphertext alone if a key was used twice (C1⊕C2 = P1⊕P2).
How Vernam's principles live on in Salsa20, ChaCha20, and AES-CTR (generating a pseudo-random keystream).
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).
Why securely delivering long random keys remains the main practical limitation of the one-time pad.
The Vernam cipher is mentioned in:
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.