Beaufort Cipher Tool

Encode and decode Beaufort ciphers with one operation. C = (K - P) mod 26 is self-reciprocal. Vigenere comparison, tabula recta, and cryptanalysis tools.

Advertisement

Free Beaufort Cipher Encoder & Decoder

The Beaufort cipher has one property that makes it worth a page of its own: encryption and decryption are the same operation. Feed it plaintext with a key and you get ciphertext. Feed that ciphertext back with the same key and the plaintext returns. There is no encode/decode switch on this tool, because there is nothing to switch. That single trait is what set it apart from the Vigènere cipher it resembles, and it is why the cipher ended up inside the Hagelin M-209 rotor machine used by the United States Army in the Second World War: a field operator with one setting and one procedure makes fewer mistakes than one who has to remember a direction.

Type a key and a message, and the output appears immediately. Everything runs in your browser; nothing is uploaded.

The Formula, and Why It Is Self-Reciprocal

Number the alphabet A=0 through Z=25. Beaufort encrypts with:

C = (K − P) mod 26

Compare that to Vigènere, which encrypts with C = (P + K) mod 26 and decrypts with P = (C − K) mod 26. Vigènere adds the key going one way and subtracts it going the other, so direction matters. Beaufort subtracts the plaintext from the key. Substitute the output back into the same formula and the reason it undoes itself falls out in one line:

(K − C) mod 26 = (K − (K − P)) mod 26 = P

The key acts as a mirror rather than an offset. Each letter is reflected about the key letter’s position, and reflecting twice returns the original. This makes Beaufort self-reciprocal (also called reciprocal, or an involution) — the same category of behaviour as Atbash, ROT13, and the XOR cipher, though Beaufort achieves it polyalphabetically with a repeating key rather than through a fixed alphabet.

A Worked Example

Encipher ATTACK with the key LEMON. The key repeats across the message, and each column computes (K − P) mod 26:

PlaintextPKeyK(K − P) mod 26Cipher
A0L1111L
T19E4(4 − 19) mod 26 = 11L
T19M12(12 − 19) mod 26 = 19T
A0O1414O
C2N1311L
K10L111B

So ATTACK becomes LLTOLB. Now run LLTOLB through with the same key: (11 − 11) mod 26 = 0 = A, (4 − 11) mod 26 = 19 = T, and so on back to ATTACK. The tool demonstrates this live — alongside every result it shows the output re-enciphered with the same key, so you can watch the original text reappear.

Note the modular wrap doing real work in row two: 4 − 19 is −15, and −15 mod 26 is 11. Handling negative remainders correctly is where hand implementations of Beaufort usually go wrong.

What This Tool Does

Four tabs, each addressing a different question:

  • Cipher — the main workspace. Enter a key and text; the result updates as you type. Toggles preserve case and pass through punctuation, spaces, and line breaks unchanged. A step-by-step view shows the per-character formula, including the exact (K − P) mod 26 arithmetic for every letter.
  • Vigènere Comparison — the same plaintext and key run through both ciphers side by side, with the mathematical relationship spelled out. This is the fastest way to see why two ciphers built on the same tabula recta produce different ciphertext.
  • Tabula Recta — the 26×26 alphabet square, interactive, with cells highlighted as you hover. Beaufort and Vigènere use the identical table but read it in different directions.
  • Cryptanalysis — letter-frequency analysis against English norms, plus key-length estimation over candidate lengths up to 15 for ciphertexts of at least twenty letters.

Three worked examples load with one click: ATTACKATDAWN with key LEMON, a short three-letter key, and a key longer than the message.

Beaufort, Vigènere, and the Variant Beaufort

Three ciphers get confused with each other constantly, so here they are together:

CipherEncryptionDecryptionSelf-reciprocal?
VigènereC = (P + K) mod 26P = (C − K) mod 26No
BeaufortC = (K − P) mod 26P = (K − C) mod 26Yes
Variant BeaufortC = (P − K) mod 26P = (C + K) mod 26No

The Variant Beaufort (sometimes called German Beaufort) subtracts the key from the plaintext rather than the other way round, which makes it exactly Vigènere decryption used as encryption — and destroys the reciprocal property. Only the true Beaufort, with the key first in the subtraction, is self-inverse. If a puzzle answer decodes to gibberish with this tool, trying the variant on the Vigènere cipher tool in reverse is usually the fix.

Breaking It

Beaufort inherits Vigènere’s weakness exactly, because it is the same polyalphabetic structure with a different arithmetic sign. The attack is two stages.

Find the key length. A repeating key of length n means every n-th letter was enciphered with the same key letter. The Kasiski examination looks for repeated substrings and factors the distances between them; the index of coincidence measures how much a candidate split resembles natural language. The Cryptanalysis tab runs the statistical version across candidate lengths and ranks them.

Solve each column. Once you know n, split the ciphertext into n columns; each is a simple monoalphabetic substitution driven by one key letter, and frequency analysis recovers it. The subtraction is what makes Beaufort feel different here: because C = K − P inverts the alphabet as well as shifting it, the frequency profile of a Beaufort column is the English distribution reflected, not merely rotated. The peak that identifies E in a Vigènere column appears mirrored in a Beaufort one — a detail that trips up anyone applying a Vigènere solver unmodified.

The practical implication: a short key over a long message is broken with pencil and paper. A key as long as the message and never reused becomes a one-time pad, which is genuinely unbreakable — but the security lives entirely in the key, not in Beaufort’s arithmetic.

Frequently Asked Questions

Why is there no encrypt/decrypt toggle?

Because Beaufort does not need one. C = (K − P) mod 26 applied twice with the same key returns the original text, so one button does both jobs. The tool shows the round trip alongside your result to prove it.

How is Beaufort different from Vigènere?

Vigènere adds the key to the plaintext; Beaufort subtracts the plaintext from the key. That sign change makes Beaufort self-reciprocal and mirrors the letter frequencies rather than rotating them. Both use the same tabula recta and have the same key-length weakness.

Is the Beaufort cipher secure?

No. It offers no protection against modern cryptanalysis and very little against a determined person with squared paper. Kasiski examination and index-of-coincidence testing recover the key length, then per-column frequency analysis recovers the key. Use it for puzzles, teaching, and CTF challenges — never for real data.

What key should I use?

For puzzles, any word. For anything approaching strength, the key must be at least as long as the message, random, and never reused — at which point you have built a one-time pad. Short repeating keys over long messages are the specific case that breaks fastest.

What was the Hagelin M-209?

A mechanical cipher machine used by the US Army from the Second World War into the Korean War. Its lug-and-pin mechanism implemented a Beaufort-style reciprocal substitution, which meant a field operator used one procedure for sending and receiving. It was designed for tactical traffic with a short useful lifetime, not for strategic secrets.

Does the tool handle punctuation, spaces, and capitals?

Yes. Punctuation, spaces, and line breaks pass through untouched by default, and case is preserved. Non-letter characters do not consume key letters, so the key advances only across the alphabetic positions.

Is my text sent to a server?

No. Enciphering, deciphering, frequency analysis, and key-length estimation all run in your browser in JavaScript. Nothing leaves your device.

My ciphertext will not decode — what should I try?

Check for the Variant Beaufort first, since it is not self-reciprocal and needs Vigènere decryption instead. If that fails, the cipher may not be polyalphabetic at all — the cipher identifier will suggest likely types, and the Caesar cipher decoder covers the simple-shift case.

Not sure which cipher you have? Use the Cipher Identifier to auto-detect cipher types from unknown ciphertext using frequency analysis and Index of Coincidence.

What Is the Beaufort Cipher?

Beaufort is a polyalphabetic substitution cipher closely related to Vigenère, with one important property: it is self-reciprocal. The same operation encrypts and decrypts, so sender and receiver use identical procedures with no separate "encrypt" and "decrypt" tables. This made it practical to implement on a reversible disk or slide.

How the Beaufort Cipher Works

Number the alphabet A=0, B=1, ..., Z=25. With key letter K and plaintext letter P:

C = (K − P) mod 26

This is reversed from Vigenère: Vigenère adds the key (C = P + K mod 26); Beaufort subtracts the plaintext from the key. Because subtraction modulo 26 is its own inverse, applying the same operation again recovers the plaintext:

P = (K − C) mod 26

A repeating keyword is used, just like Vigenère — the key cycles through its letters across the message.

Worked Example

Encrypt "HELLO" with the key "FORT" (repeating: F O R T F).

  • H(7), key F(5): (5 − 7) mod 26 = 24 → Y
  • E(4), key O(14): (14 − 4) mod 26 = 10 → K
  • L(11), key R(17): (17 − 11) mod 26 = 6 → G
  • L(11), key T(19): (19 − 11) mod 26 = 8 → I
  • O(14), key F(5): (5 − 14) mod 26 = 17 → R

Ciphertext: "YKGIR". Decrypt by applying the same operation: (5 − 24) mod 26 = 7 → H, and so on, recovering "HELLO". That symmetry is what "reciprocal" means in practice.

Beaufort vs. Vigenère vs. Variant Beaufort

  • Vigenère: C = (P + K) mod 26 — encrypt adds, decrypt subtracts.
  • Beaufort: C = (K − P) mod 26 — same operation both ways.
  • Variant Beaufort ("German Variant"): C = (P − K) mod 26 — Vigenère in reverse; not reciprocal.

History

The cipher is named after Sir Francis Beaufort, the Royal Navy admiral who also created the Beaufort wind scale. He proposed it around 1857. The British Royal Navy used Beaufort-style ciphers on disks and slide rules through the 19th and early 20th centuries because the reciprocal property simplified manual operation and reduced training error.

When to Use the Beaufort Cipher

Education and puzzles only. It is a good teaching example because small changes in algebraic structure (subtraction vs. addition) produce useful properties (self-inverse encryption) without improving security. It is also a favorite in CTF challenges that include it specifically because solvers try Vigenère first and fail. Do not use it for any real-world secrecy requirement.

Security and Cryptanalysis

Beaufort has the same security profile as Vigenère and is broken by the same techniques:

  • Kasiski examination — repeated ciphertext n-grams reveal the key length, since identical plaintext segments at the same key offset produce identical ciphertext.
  • Friedman / Index of Coincidence test — Beaufort ciphertext has IoC around 0.038–0.045 (flatter than English's 0.067), and analyzing IoC for assumed key lengths peaks at the correct length.
  • Per-column frequency analysis — once the key length is known, each column is a single key letter, reducing the problem to 26 independent Caesar cracks.

Modern solvers recover Beaufort keys of length 4–8 from a few hundred characters of ciphertext in under a second. Practical fingerprint: when a Vigenère key produces gibberish but reversing the direction produces sensible text, the cipher is often Beaufort.

Related Ciphers

  • Vigenère cipher — the closest relative; same statistical fingerprint, different algebraic form.
  • Caesar cipher — the degenerate case of a polyalphabetic cipher with key length 1.
  • Affine cipher — another linear-algebra cipher over modular arithmetic, but monoalphabetic.

If you have unknown ciphertext with a flat letter distribution and no readable words, it is likely polyalphabetic — start with the Cipher Identifier to rank Vigenère, Beaufort, and related candidates.

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.