Vernam Cipher
Vernam’s teleprinter cipher used binary addition; developed in 1917 and patented in 1919
XOR gives perfect secrecy only with an independent, uniformly random secret pad at least as long as the message, used once. No authentication.
Why This Matters
Gilbert Vernam’s 1917 XOR-based teleprinter cipher is an early ancestor of modern XOR-based stream encryption. ChaCha20, AES-CTR, and AES-GCM also combine data with a keystream using XOR; Vernam’s patent concerned a telegraphic system.
Gilbert Vernam was an AT&T engineer who in 1917 invented an automatic cipher (patented 1919) for teleprinter communications. Messages on punched paper tape were XOR'd with a key tape character by character. A uniformly random, independent, secret key used only once gives the one-time-pad construction. Vernam’s automatic tape system and the perfect-secrecy conditions are distinct ideas.
The Vernam cipher is an early ancestor of modern XOR-based stream encryption. ChaCha20, AES-CTR, and AES-GCM also use XOR to combine data and a keystream. The difference is that modern ciphers generate their keystream from a short key and a nonce, rather than requiring a physical tape as long as the message.
The Vernam cipher operates at the bit level using the XOR (exclusive or) operation. Each bit of the plaintext is combined with the corresponding bit of the key.
Ciphertext = Plaintext XOR Key (bitwise) H = 01001000 K = 10110100 (key byte) C = 11111100 (ciphertext) Decryption is identical: C XOR K = P (XOR is its own inverse) When key tape is: Random + same length + used once → One-Time Pad (unbreakable) Repeating tape → periodic-key weaknesses; a secure pseudorandom generator instead supports computational security
The elegance of XOR is that applying the same key a second time returns the plaintext: C XOR K = P. There is no separate decryption algorithm — the demo's Decrypt button simply reads the hex bytes back in and XORs them with the key again.
About this demo: Plaintext is normalized to the letters A–Z, XORed byte-by-byte with the key, and the ciphertext is displayed as two hexadecimal digits per byte — so Decrypt expects hex input, not letters. Leave the key blank and the demo generates a random pad using the browser's secure random source, appending it to the output as [Key: …]. A key shorter than the message is rejected rather than repeated, and a raw byte key can be supplied as hex:<bytes>. The displayed pad is not secret from the browser; this is an educational calculation, not a confidential channel.
For binary encryption, reusing the same keystream gives C1 ⊕ C2 = P1 ⊕ P2. This exposes relations that language guesses or known plaintext may exploit. A biased natural-language key is different from a cryptographically generated pseudorandom keystream: the latter aims for computational security, not perfect secrecy.
VENONA: VENONA exploited reused decimal additive pages. Cancellation is the analogous idea, but its digitwise arithmetic and codebook-recovery problem differed from this binary XOR example.
| Concept from Vernam | Modern Evolution |
|---|---|
| XOR as cipher operation | Typical XOR-based stream encryption: C = P ⊕ keystream |
| Key tape = keystream | ChaCha20 generates 512-bit blocks of keystream per counter value |
| Reused key = catastrophic failure | Nonce uniqueness: AES-GCM fails catastrophically on nonce reuse |
| Automatic teleprinter encryption | Hardware crypto acceleration: AES-NI CPU instructions |
A short Vernam message, exactly as the demo above produces it. Use what you just learned.
Key: KEYS · Hint: each pair of hex digits is one XORed byte. Paste ciphertext and key into the demo above, or work the XOR by hand.
Reusing keystream exposes relations between plaintexts. A uniform, independent, secret, single-use message-length pad provides perfect secrecy, but not authentication.
| Exhibit | 37 of 172 |
| Era | 1917 |
| Trust | Secure (Modern) |
| Inventor | Gilbert Vernam |
| Year | 1917 |
| Broken By | Key reuse / depth attack |