One-Time Pad
XOR a message with a truly random key as long as itself — the only cipher proven unbreakable, and the only one almost nobody can use.
Contents
One-Time Pad
The one-time pad is the unicorn of cryptography: a cipher mathematically proven to be unbreakable. The recipe is almost embarrassingly simple. Take a key that is truly random, as long as the message, and never reused, then combine it with the message bit by bit using XOR (exclusive-or, addition mod 2):
XOR is its own inverse, so the receiver — who has the same pad — just XORs again to peel the key back off. Invented in 1882 and patented by Gilbert Vernam in 1919, it is also called the Vernam cipher.
Why it is perfectly secret
Here is the magic. For any ciphertext, every possible plaintext of the same length is equally likely, because for each candidate plaintext there is exactly one key that would have produced that ciphertext. The ciphertext therefore reveals nothing: an attacker who intercepts 1011 cannot tell whether you sent YES or NO or random noise — all are consistent with some key.
Watch the key drown the message
The key is a fresh fair coin for every bit — a binary Random Walk with no pattern to grab onto. XORing a message with it produces ciphertext that is itself indistinguishable from random. Below, the structured message bits vanish under a random key, and XORing the key back in restores them perfectly.
Why almost nobody uses it
If it is perfect, why is the world not built on it? Because the very thing that makes it secure makes it impractical: the key must be as long as everything you will ever send, truly random, shared in advance through some already-secure channel, and never reused. To send a gigabyte secretly you must first secretly share a gigabyte of key — which raises the same problem you started with.
The one-time pad is reserved for the highest-stakes links — diplomatic and intelligence channels — where couriers can hand-deliver key material. For everyone else, the practical path is to stop sharing huge secret keys altogether and let mathematics carry the secret instead. That is the promise of Diffie–Hellman and Public-Key Cryptography.