SimplyCalculated.org

Beaufort Cipher Encoder & Decoder

The Vigenère cipher's elegant sibling: subtract the plaintext from the key letter (C = K − P) instead of adding them, and the exact same operation decrypts as well as encrypts. Type on either side with a keyword to see it work. Everything runs locally in your browser.

100% private: everything is processed in your browser's memory — nothing you enter is uploaded to a server, logged, or stored.

Beaufort Cipher

Only the letters A–Z in the key are used — case and digits are ignored. Non-letter characters in your message pass through unchanged and do not advance the key. Because the Beaufort rule C = (K − P) mod 26 is its own inverse, typing on either side encrypts or decrypts with the very same operation.

What Is the Beaufort Cipher?

The Beaufort cipher is a polyalphabetic substitution cipher — one of the family that also includes the Vigenère and the similar Autokey system — invented by Sir Francis Beaufort and published posthumously in 1857, the year he died. Where the Vigenère cipher encrypts each letter by adding the key letter to it, the Beaufort cipher subtracts the plaintext from the key: C = (K − P) mod 26. Since subtracting C back out of K recovers P, the same formula works in both directions. This self-inverse property makes it a reciprocal cipher, which historically mattered a great deal: a reciprocal transformation means one table, one disk, or one machine setting handles both enciphering and deciphering, halving the risk of operator error.

The man behind the name is better remembered for the Beaufort wind-force scale, the 0–12 scale sailors still use to describe sea conditions. The cipher shares his name because he devised it near the end of his life, and his brother William published the details in 1857, shortly after Beaufort's death, as a small card titled "Cryptography, A System of Secret Writing."

How the Beaufort Cipher Works

Assign each letter a number: A = 0, B = 1, …, Z = 25. With a key letter of value K and a plaintext letter of value P, the ciphertext letter is C = (K − P) mod 26. "Mod 26" means the result wraps around the alphabet, so a negative difference like −3 becomes 23 (X). The key letter is drawn from the keyword in sequence and repeats cyclically; non-letter characters in the message pass through unchanged and do not advance the key.

Key letter K Plain P K − P Cipher C
K (10) H (7) 3 D
E (4) E (4) 0 A
Y (24) L (11) 13 N
K (10) L (11) −1 → 25 Z
E (4) O (14) −10 → 16 Q

Step-by-Step Example

Encrypt the word "HELLO" with the key "KEY". Write the key letters underneath the message and subtract, position by position:

Plain:  H  E  L  L  O
Key:    K  E  Y  K  E
Cipher: D  A  N  Z  Q

Reading the bottom row gives DANZQ. Now decrypt DANZQ with the same key: D (3) against K (10) gives 10 − 3 = 7, the letter H — and each position recovers the original, so the ciphertext returns to HELLO. Type either word into the tool above to watch the correspondence live.

Example Reference Table

Plain Text Key Ciphertext
HELLO KEY DANZQ
ATTACK AT DAWN LEMON LLTOLB ET LNPR
Hello, World! KEY Danzq, Cwnnh!
SimplyCalculated TEAL BwowigYlicgatlwi
We attack at dawn KEY Oa yrlyiu yr byor

Paste any plain-text row with its key into the tool to confirm the ciphertext, or paste the ciphertext with the same key to confirm it decodes back — the symmetry of the cipher means either direction passes through the same function.

Security and Cryptanalysis

The Beaufort cipher offers no real security by modern standards, and for exactly the same reason the Vigenère cipher doesn't: it is a periodic polyalphabetic substitution. Because the key repeats every few letters, the ciphertext contains statistical fingerprints of the key length. Friedrich Kasiski's 1863 examination finds repeated ciphertext digraphs and measures the distances between them, whose common factor reveals the key period; once the period is known, every key letter stands alone as a simple Caesar-style substitution that frequency analysis cracks easily. The key space — a keyword, so at most a few hundred thousand possibilities in practice — adds no real strength. Its historical value lay in its convenience: reciprocal, compact, and cheap to use by hand. For actual secrecy today, use a modern algorithm; this tool exists for learning, puzzles, and curiosity.

Troubleshooting & Common Mistakes

My decrypted output looks nothing like my original message

The key must match exactly — case is ignored and only letters count, so "LEMON" and "lemon" are identical, but "LEMONS" is a different key. Double-check the key and confirm the ciphertext was copied completely; a single missing character shifts every key letter after it.

My output matches my input exactly

An empty key (no letters A–Z) makes the cipher the identity transformation — everything passes through unchanged. Type a real keyword and the text will scramble.

I entered a key with digits or symbols — is that a problem?

No. Only the letters in the key are used; "k3y!" and "KEY" produce identical output. The same is true in the message: spaces, punctuation, and digits ride along unchanged and never consume a key letter.

How This Cipher Compares to Other Classical Ciphers

Beaufort is one of several classical ciphers covered on this site. It is a close relative of Vigenère — built on the same polyalphabetic keyword idea — but its self-reciprocal operation sets it apart from every other cipher in the table below.

Cipher Mechanism What Makes It Different
Caesar Cipher Substitution Shifts every letter by one fixed number (the key) through the alphabet — the simplest classical substitution cipher.
Atbash Cipher Substitution (fixed) A special case of substitution with no key at all — it always mirrors the alphabet (A↔Z, B↔Y, ...).
Vigenère Cipher Polyalphabetic substitution Repeats a keyword to shift each letter by a different amount, defeating simple frequency analysis that breaks Caesar.
Beaufort Cipher (this page) Polyalphabetic substitution (reciprocal) A variant of Vigenère's idea that is self-reciprocal — the same operation both encrypts and decrypts.
Playfair Cipher Digraph substitution Encrypts letters two at a time using their positions in a 5×5 key square — the first practical digraph cipher (1854).
Affine Cipher Mathematical substitution Encrypts using a linear function (ax + b mod 26) with two keys instead of one shift value.
ROT47 Substitution (extended range) Applies a Caesar-style shift across the full printable ASCII range, not just letters — used to obfuscate text online (e.g. spoilers), not for security.
Rail Fence Cipher Transposition Rearranges letter order in a zigzag pattern instead of substituting letters — a fundamentally different technique from every cipher above.
A1Z26 Encoding (not a cipher) Simply maps each letter to its position number (A=1...Z=26) — a puzzle/encoding convention, not intended for real secrecy.
NATO Phonetic Alphabet Encoding (not a cipher) Replaces each letter with a spoken code word (Alfa, Bravo, Charlie…) for reliable voice transmission on noisy radios — built for clarity, not secrecy.

Frequently Asked Questions

How is the Beaufort cipher different from the Vigenère cipher?
Both are polyalphabetic keyword ciphers built on the same tabula recta, but they subtract in opposite directions. Vigenère encrypts with C = (P + K) mod 26 and decrypts with P = (C − K) mod 26 — two different operations. Beaufort always uses C = (K − P) mod 26, and because subtracting the other way around recovers the original letter, the identical operation decrypts. That single symmetry is the whole difference; everything else — key handling, letter-by-letter arithmetic, weakness to Kasiski examination — is shared.
Why is Beaufort called a "reciprocal" cipher?
Reciprocal means the encryption transformation is its own inverse: applying it twice with the same key returns the original text. Because C = (K − P) mod 26, decrypting just recomputes C = (K − C) mod 26 = P. This is a genuinely useful property in the field — a single machine setting or table can both encipher and decipher, which is why reciprocal ciphers were prized before electronics.
Who invented the Beaufort cipher, and when?
It is named after Sir Francis Beaufort, the Irish hydrographer best known for the wind-force scale still used at sea today. He devised the cipher near the end of his life, as an improvement on the Vigenère; it was published posthumously in 1857, the year he died, by his brother William.
Is the Beaufort cipher secure?
No. Like Vigenère, it is a periodic polyalphabetic substitution, and once the key length is recovered — usually via the Kasiski examination or Friedman's index of coincidence — each key letter can be cracked independently with frequency analysis. The key space itself is the same size as Vigenère's, which is far too small for modern standards. It belongs firmly in the puzzle-and-teaching category, alongside every other classic cipher on this site.
What does it mean for the key to "advance" only over letters?
In the classic usage implemented here, punctuation, digits, and spaces in the message are copied straight into the output and do not consume a key letter — the key only steps forward when a letter is enciphered. So "HELLO!" with key "AB" advances the key over H, E, L, L, O only, and the "!" is passed through untouched. This keeps letter alignment predictable and matches how the cipher was historically written by hand.
What key should I use?
Any word or phrase works — only the letters A–Z matter, and case is ignored, so "key", "KEY", and "k3y!" are all the same key "KEY". An empty key (no letters at all) makes the cipher the identity transformation, so a real key is required to see any scrambling. Choose something easy to share with whoever needs to read the message, since the same key must be used on both sides.

Formula last verified August 22, 2026 against our published methodology .