Beaufort Cipher (How it Works, Formula & Example)

Learn how to use the Beaufort cipher step by step, understand its formula Cᵢ = (Kᵢ − Pᵢ + 26) mod 26, and try an interactive Beaufort cipher tool to encrypt and decrypt in seconds.

Reviewed by the Let's Cipher editorial team Reading time: ~6 min Level: Intermediate

The Beaufort cipher is the only classical polyalphabetic cipher that is fully reciprocal — the same key and the same operation both encrypt and decrypt.

The Beaufort cipher encrypts text by subtracting the plaintext letter from the key letter using modular arithmetic.

In a nutshell

The Beaufort cipher is a reciprocal polyalphabetic cipher where the same formula encrypts and decrypts using a key. It is based on the operation (Kᵢ − Pᵢ) mod 26: it subtracts the plaintext index from the key index. Unlike the Vigenère cipher, it is completely self-inverse — encrypting twice returns the original text.

The Beaufort cipher is a polyalphabetic and reciprocal cryptographic method created by British Admiral Francis Beaufort in the 19th century. It uses a text key that generates variable letter-by-letter shifts, and its formula makes it a reciprocal cipher: encrypting and decrypting are exactly the same operation.

  • Type: Reciprocal polyalphabetic cipher
  • Key: Word or phrase (letters A–Z)
  • Formula: Cᵢ = (Kᵢ − Pᵢ + 26) mod 26
  • Security: Low (vulnerable to Kasiski)

Origin and History of the Beaufort Cipher

The Beaufort cipher takes its name from British Admiral Sir Francis Beaufort (1774–1857), best known today for the wind speed scale that bears his name. Beaufort developed this system as an improved variant of the then-popular Vigenère cipher; it is structurally similar to Vigenère but with a subtle mathematical difference of enormous practical consequence: the formula is completely reciprocal.

Unlike the Caesar cipher — which is monoalphabetic (one fixed shift for the whole message) — Beaufort is a polyalphabetic cipher: the shift varies letter by letter according to the key. Whereas Vigenère adds the key index to the plaintext index modulo 26, Beaufort subtracts: Cᵢ = (Kᵢ − Pᵢ + 26) mod 26. This difference eliminates the need for a separate decryption operation, since applying the same formula recovers the original message — a property highly valued in 19th-century naval contexts where operational simplicity was critical.

Related to the Atbash cipher in its self-inverse nature (Atbash is also reciprocal, though monoalphabetic), Beaufort extends that property to the polyalphabetic domain. The same classical cryptanalysis techniques that attack Vigenère apply here, but with frequency distributions reflected rather than shifted.

What is the Beaufort cipher used for?

Naval history

Originally used in 19th-century British naval communications thanks to its simplified operation: a single procedure encrypts and decrypts.

Education

Excellent for teaching the concept of reciprocal ciphers and the mathematical properties of modular arithmetic in cryptography.

CTF & puzzles

Appears in Capture the Flag (CTF) competitions and escape rooms as a more advanced Vigenère variant that challenges those who only know the standard version.

Algebraic reference

Its reciprocal property serves as a case study in modular algebra and is a conceptual basis for understanding modern symmetric stream ciphers.

How the Beaufort cipher works step by step

  • Choose the key: Select a word or phrase made up of letters only (A–Z). This key is repeated (as in Vigenère) as many times as needed to match the length of the message.
  • Index each character: Each letter, both in the plaintext and the key, is converted to its numeric index (A=0, B=1, …, Z=25).
  • Apply the Beaufort formula: Cᵢ = (Kᵢ − Pᵢ + 26) mod 26. Subtract the plaintext index from the key index (add 26 to avoid negative numbers before the modulo).
  • Convert back to a letter: The numeric result is converted back to the corresponding alphabet letter.
  • Identical decryption: To decrypt, apply exactly the same formula with the same key. This is the reciprocal property that sets Beaufort apart from all other classical polyalphabetic ciphers.

Follow this Beaufort cipher step by step guide, apply the Beaufort cipher formula to each letter, and verify every result instantly with the Beaufort cipher tool below.

Beaufort Cipher Simulator

Beaufort is reciprocal: encrypting and decrypting use the same button and the same key.

Why a single button? Beaufort is the only classical cipher where applying the operation twice restores the original text. Encrypt the result with the same key and you will get your starting text back.
Beaufort cipher example: type HELLO as text, KEY as key, and click Encrypt / Decrypt → you will get RIJVS. Click again on the result and you will recover HELLO.

Beaufort cipher example explained with a table

This Beaufort cipher example step by step shows exactly how the Beaufort cipher formula Cᵢ = (Kᵢ − Pᵢ + 26) mod 26 operates on each letter. Use the Beaufort cipher tool above to verify.

Plaintext: HELLO
Key: KEY (repeated: KEYKE)
Formula: Cᵢ = (Kᵢ − Pᵢ + 26) mod 26

Pos. Plaintext (Pᵢ) Key (Kᵢ) Calculation Ciphertext (Cᵢ)
1 H (7) K (10) (10 − 7 + 26) mod 26 = 3 D
2 E (4) E (4) (4 − 4 + 26) mod 26 = 0 A
3 L (11) Y (24) (24 − 11 + 26) mod 26 = 13 N
4 L (11) K (10) (10 − 11 + 26) mod 26 = 25 Z
5 O (14) E (4) (4 − 14 + 26) mod 26 = 16 Q

Encrypted result: DANZQ

Reciprocal check: encrypt DANZQ with key KEYKE using the same Beaufort formula and you will recover HELLO.

Beaufort vs Cæsar vs Vigenère

Feature Caesar Vigenère Beaufort
Type Monoalphabetic Polyalphabetic Reciprocal polyalphabetic
Key Number (1–25) Word / phrase Word / phrase
Encryption formula (Pᵢ + K) mod 26 (Pᵢ + Kᵢ) mod 26 (Kᵢ − Pᵢ + 26) mod 26
Decryption formula (Cᵢ − K + 26) mod 26 (Cᵢ − Kᵢ + 26) mod 26 Same as encryption ✓
Reciprocal No No Yes ✓
Frequency resistance Very low Medium Medium
Main attack Brute force (26 keys) Kasiski + frequencies Kasiski + reflected frequencies
Historical use Ancient Rome 16th-century European diplomacy 19th-century British Navy

Why the Beaufort cipher is reciprocal

The reciprocity of Beaufort is not a coincidence — it is a direct consequence of its formula. In modular arithmetic, a function is called an involution when applying it twice returns the original value.

Beaufort encrypts with Cᵢ = (Kᵢ − Pᵢ + 26) mod 26. If we take that result Cᵢ as new input and apply the same formula:

Start with plaintext: Pᵢ

Encrypt: Cᵢ = (Kᵢ − Pᵢ + 26) mod 26

Apply again to Cᵢ: (Kᵢ − Cᵢ + 26) mod 26

= (Kᵢ − (Kᵢ − Pᵢ) + 26) mod 26 = Pᵢ

The result is exactly the original plaintext. This contrasts with the Vigenère cipher (which is not reciprocal) and makes Beaufort the only truly reciprocal classical polyalphabetic cipher — a property it shares conceptually with the XOR operation of modern cryptography.

How to break the Beaufort cipher: classical attacks

Breaking the Beaufort cipher step by step requires two techniques: the Kasiski test to estimate the key length, and reflected frequency analysis to reveal each key letter.

Kasiski test

As in Vigenère, if the key repeats, certain plaintext sequences produce identical ciphertext sequences. The distance between these repetitions is a multiple of the key length. Finding the greatest common divisor of several such distances reveals the likely key length.

Index of Coincidence (Friedman)

Once the key length is known, the ciphertext characters are grouped into columns. Each column is solved as an inverted Caesar cipher: in Beaufort, frequencies are reflected relative to the normal alphabet, not shifted. This detail distinguishes Beaufort from Vigenère during column-by-column frequency analysis.

Beaufort cipher variants and related ciphers

1. Beaufort Variant

Also called “Pseudo-Beaufort” or “Variant Beaufort”, it uses the formula (Pᵢ − Kᵢ + 26) mod 26. It is essentially a Vigenère decryption: encrypting with the Variant Beaufort is equivalent to decrypting with Vigenère using the same key.

2. Vigenère Cipher

The best-known polyalphabetic cipher. Uses the formula (Pᵢ + Kᵢ) mod 26. No reciprocal property, but functionally very similar. Beaufort can be viewed as an algebraic reflection of Vigenère.

3. Autokey Cipher

A Vigenère variant where the key is not repeated but extended with the plaintext itself. Eliminates the Kasiski weakness and is significantly more resistant to classical statistical cryptanalysis.

Advantages and disadvantages of the Beaufort cipher

Advantages

  • Unique reciprocal property: encrypting and decrypting are the same operation, enormously simplifying manual use and reducing operational errors.
  • Greater resistance than Caesar: by changing the substitution alphabet with each letter, it hides simple frequency patterns better than monoalphabetic ciphers.
  • Simple implementation: requires only basic modular arithmetic, ideal for manual or pedagogical use.
  • Valuable conceptual base: its algebra naturally introduces stream ciphers and the XOR logic of modern cryptography.

Disadvantages

  • Vulnerable to Kasiski: if the key is short or reused, the Kasiski test can estimate its length and break the cipher with statistical analysis.
  • Not suitable for real use: completely insecure for protecting modern information. Any basic statistical tool can break it with enough text.
  • Insecure key distribution: sender and receiver must share the same key over a pre-existing secure channel — a problem the cipher itself does not solve.
  • No authentication: includes no integrity or message-authentication mechanism, making the ciphertext susceptible to manipulation.

How to identify a text encrypted with Beaufort

If you intercept an unknown ciphertext, these signals suggest a Beaufort cipher:

Flat frequency distribution

The index of coincidence is low (similar to Vigenère), indicating a polyalphabetic cipher. No letter dominates with the 10–14% frequency characteristic of monoalphabetic ciphers.

Periodic repetitions

If the key is short, repeated sequences appear whose distance is a multiple of the key length. This is identical to the Kasiski signature in Vigenère.

Reflected column frequencies

Unlike Vigenère (where frequencies are shifted), in Beaufort the frequencies in each column appear reflected relative to the source language — a useful diagnostic sign for the cryptanalyst.

Tip: if a text looks like Vigenère but shift-based column analysis does not work, try the Beaufort formula. The frequency distribution in each column may be a reflection of the alphabet rather than a shift.

Beaufort cipher exercises

Practise with these Beaufort cipher example step by step exercises. Use the simulator above to verify your answers.

Exercise 1 — Basic

Encrypt the word CAT with key KEY using the Beaufort formula.

  1. Convert each letter to an index (A=0 … Z=25).
  2. Apply (Kᵢ − Pᵢ + 26) mod 26.
  3. Convert the result back to a letter.

Hint: C=2, A=0, T=19 | K=10, E=4, Y=24

Exercise 2 — Reciprocity

Given the ciphertext DANZQ and key KEYKE, decrypt it.

Remember: in Beaufort, encrypting and decrypting are identical. Use exactly the same formula.

Hint: the result is one of the most common English greetings.

Exercise 3 — Analysis

You have a Beaufort-encrypted text: BKXMF ZIQOB (unknown 3-letter key).

  1. Estimate the key length using repetitions.
  2. Split the letters into 3 groups (one per key position).
  3. Apply reflected frequency analysis to each group.
  4. Reconstruct the key letter by letter.

How secure is the Beaufort cipher?

How secure is the Beaufort cipher?

The Beaufort cipher is not secure for modern communications. Like the Vigenère cipher, it presents critical vulnerabilities against classical cryptanalysis techniques:

  • Kasiski test: if the key is reused, repetitions in the ciphertext allow the key length to be estimated with high precision.
  • Reflected frequency analysis: once the key length is known, each position is solved independently using the language’s frequency distribution. In Beaufort, frequencies appear reflected rather than shifted, making them equally identifiable.
  • Short keys = fast break: keys shorter than 8 letters are vulnerable with just a few hundred characters of ciphertext.

Conclusion: the Beaufort cipher is an educational and recreational tool, not a real security mechanism. For secure communications, use modern standards such as AES-256.

Frequently asked questions about the Beaufort cipher

What is the Beaufort cipher?

The Beaufort cipher is a polyalphabetic cryptographic system invented by British Admiral Francis Beaufort in the 19th century. Its most notable feature is that it is reciprocal: the same operation with the same key serves both to encrypt and to decrypt. It uses the formula Cᵢ = (Kᵢ − Pᵢ + 26) mod 26, differing from the Vigenère cipher in the order of the subtraction.

Why is the Beaufort cipher reciprocal?

Because its formula is algebraically self-inverse. Applying (Kᵢ − Pᵢ) mod 26 to the plaintext gives the ciphertext, and applying (Kᵢ − Cᵢ) mod 26 to the ciphertext gives back the plaintext. Since the formula is the same (only the name of the input variable changes), the same process works for both directions. Mathematically, Beaufort is an involution over ℤ₂₆.

What is the difference between Beaufort and Vigenère?

The difference is mathematical but fundamental. Vigenère uses (Pᵢ + Kᵢ) mod 26 to encrypt and (Cᵢ − Kᵢ + 26) mod 26 to decrypt. Beaufort uses (Kᵢ − Pᵢ + 26) mod 26 for both operations. This means Beaufort has no distinction between encrypting and decrypting, whereas in Vigenère they are inverse operations.

Is the Beaufort cipher secure today?

No, the Beaufort cipher is not secure for modern communications. It is vulnerable to the same attacks as Vigenère: the Kasiski test and Friedman’s index of coincidence can determine the key length with sufficient ciphertext, after which each position is solved independently as a simple substitution cipher.

What key length is recommended for Beaufort?

In educational or recreational contexts, any length works. For maximum theoretical resistance within the classical system, the key should be as long as the message and completely random (which approximates a One-Time Pad). Short keys (fewer than 8 characters) are easily broken with the Kasiski test if sufficient ciphertext is available.

Where is the Beaufort cipher used today?

Today the Beaufort cipher is not used for real security. It appears mainly in educational contexts to illustrate reciprocal ciphers and modular arithmetic, in CTF challenges (Capture the Flag) as an advanced Vigenère variant, and in escape rooms and cryptographic puzzles. It is also cited in cryptographic history texts for its elegant mathematical property.

Beaufort cipher summary

The Beaufort cipher is a 19th-century reciprocal polyalphabetic cipher that uses the formula Cᵢ = (Kᵢ − Pᵢ + 26) mod 26 to encrypt and decrypt with the same operation. Its defining feature is the reciprocal property: applying the algorithm twice with the same key returns the original text — unique among classical polyalphabetic ciphers.

Key

Any word or phrase made up of letters A–Z, repeated to cover the message.

Differentiator

The only truly reciprocal classical polyalphabetic cipher: encrypt = decrypt.

Security

Insecure for real use. Vulnerable to Kasiski and reflected frequency analysis.

Current use

Education, CTF, escape rooms, and classical cryptography history.