Read this lesson as text
One-Time Pad
Cryptography · Axiom Academy
The only theoretically unbreakable cipher in cryptography The One-Time Pad uses a simple but powerful principle: combine your message with a random key using XOR (exclusive OR) for binary data, or modular addition for letters. Where P = plaintext, K = key, C = ciphertext, and ⊕ = XOR operation For Letter Messages (Modular Arithmetic) Encryption: C = (P + K) mod 26 Decryption: P = (C - K) mod 26 Where letters are numbered A=0, B=1, ..., Z=25 2. Three Critical Requirements For the One-Time Pad to provide perfect secrecy, three conditions must be met simultaneously: Truly Random Key: The key must be generated by a truly random process, not a pseudo-random algorithm. Any pattern in the key compromises security. Key Length Equals Message Length: The key must be at least as long as the message being encrypted. Every bit or character requires a unique random key bit or character. Never Reuse a Key: Each key must be used exactly once and then destroyed. This is the "one-time" in One-Time Pad. Key reuse is catastrophic. 3. Shannon's Proof of Perfect Secrecy In 1949, Claude Shannon proved that the One-Time Pad provides perfect secrecy. His insight was profound: when using a truly random key as long as the message, the ciphertext is equally likely to decrypt to any possible message of that length. Suppose you intercept the ciphertext "10110". With the right keys, this could decrypt to: Since all keys are equally probable, all plaintexts are equally probable. The attacker learns nothing.
This is the written version of the interactive lesson above. See the full Cryptography course.