Ciphers · one-time padVernam Cipher ⊕

The Vernam cipher is the one-time pad — the only cipher that cannot be broken if the key is random, used once and at least as long as the text. Encrypt by addition modulo the alphabet or by XOR of letter numbers, and generate a random key of the right length right in your browser.

Everything runs in your browser — the text goes nowhere

01Encode02Diagram03How it works04Questions05Related
01

Encode

the key is random, used once and as long as the text
Alphabet
Mode
Key · 6 letters needed
Plain text
Result
English
lxfoph
The link will contain the text (up to 500 characters) and settings — share it with care.
02

Diagram

addition modulo the alphabet
Texta0t19t19a0c2k10
Keyl11e4m12o14n13x23
Suml11x23f5o14p15h7

Under each letter is its number counted from zero. The numbers are added and the remainder of division by 26 is taken.

03

How it works

Adding the key

attack + lemonx → lxfoph

The number of each text letter is added to the number of the key letter, modulo 26. Decoding subtracts it.

XOR of numbers

h ⊕ k: 8 ⊕ 11 = 3 → c

The numbers are written in binary and added bit by bit. The same key applied to the ciphertext numbers returns the letters.

Why it cannot be broken

key length = text length

A random key, as long as the text and used only once, makes every decoding of the same length equally likely.

04

Frequently asked questions

Each letter of the text gets a key letter added to it: the numbers are summed and the remainder after division by the alphabet length is taken. ATTACK with the key LEMONX becomes LXFOPH. The second option is XOR: letter numbers are written in binary and added bit by bit. Either way, the key must be at least as long as the text.

Updated