Beaufort cipher — one keyed operation that encrypts and decrypts

The Beaufort cipher subtracts each letter from a repeating key letter, which makes it its own inverse; enter a key, paste plain text to encrypt or ciphertext to decrypt, and the same step does both.

Live demo · real result from this tool

Result

Ckmpvc pvw piwu jogi ua pvw riwuuk

Processed on your device — nothing is uploaded.

How to use the Beaufort cipher tool

  1. Enter the Key. The default is FORTIFICATION, the key used in a well-known textbook example.
  2. Type or paste your message into Your text.
  3. Read the Result. That is the ciphertext if you entered plain text, or the plain text if you entered ciphertext.
  4. Share the key separately with the person who will read the message.

What it does and when to use it

The Beaufort cipher is named after Sir Francis Beaufort, the admiral best known for the wind force scale. It uses a keyword like the Vigenère cipher, but its arithmetic is reversed, so the operation that encrypts also decrypts. That reciprocal property made it convenient for hand use, and the same idea was later built into some mechanical cipher machines.

Today it is a puzzle and teaching cipher. It does not protect data against anyone who knows classical cryptanalysis. To compare it with its close relatives, try the Vigenère cipher, the autokey Vigenère cipher, which avoids a repeating key, and the Gronsfeld cipher, which uses digits as the key.

How it works

Number the letters A = 0 to Z = 25. The key is repeated along the letters of the message, and for each letter:

C = (K − P) mod 26

Take the first letter of the textbook example: the key letter F is 5 and the plain letter D is 3, so 5 − 3 = 2, which is C. Next, key O (14) and plain E (4) give 10, which is K.

Only the letters A to Z and a to z are changed, and each keeps its case. Spaces, digits, punctuation and accented letters pass through and do not use up a key letter. The key is cleaned the same way: everything except its letters is ignored. The calculation runs in your browser.

Worked examples

Results from the tool:

DEFENDTHEEASTWALLOFTHECASTLE   key FORTIFICATION  →  CKMPVCPVWPIWUJOGIUAPVWRIWUUK
Meet at 6, Bob!                key Key            →  Yaur ef 6, Jqx!
Yaur ef 6, Jqx!                key Key            →  Meet at 6, Bob!
HELLO                          key Z              →  SVOOL

The first is the classic test case. The second and third show the same operation going both ways, with the 6, the comma and the spaces untouched. With the one-letter key Z, Beaufort becomes Atbash, the mirror alphabet, so HELLO turns into SVOOL just as it would in the Atbash cipher.

Limits and tips

  • Longer keys that are not English words are harder to break by hand, though still not secure.
  • Because spaces are kept, word lengths show. Remove spaces before encrypting if that matters for your puzzle.
  • Letters outside A to Z, such as é or ß, are not encrypted. Replace them with plain letters if they would give the message away.

Frequently asked questions

Where is the decrypt button?
There is none, because it is not needed. If C = K − P, then K − C = P, so applying the same operation to the ciphertext with the same key returns the plain text. Paste the ciphertext into Your text and keep the key.
How is Beaufort different from Vigenère?
Vigenère adds the key letter to the plain letter (P + K); Beaufort subtracts the plain letter from the key letter (K − P). That small change makes Beaufort reciprocal, so one routine handles both directions. The same message and key give different ciphertext in the two ciphers.
What does the key accept?
Any text, but only its letters are used, and case does not matter. FORTIFICATION, fortification and Fort-ification are the same key. A key with no letters at all, such as 42, gives the message "The key needs at least one letter."
Is the Beaufort cipher safe for real secrets?
No. It has the same weakness as Vigenère, a repeating key, so the key length can be found from repeated patterns and the rest falls to frequency analysis. Use it for puzzles, geocaches and lessons only.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close