Beaufort Cipher

Encode and decode messages with the reciprocal Beaufort cipher.

How it is calculated

Each letter is turned into a number, A = 0 to Z = 25. For plaintext letter P and the current key letter K, the output letter is C = (K − P) mod 26. The key repeats cyclically, and it advances only when a letter is processed. Spaces, digits and punctuation are copied unchanged and do not consume key letters. Upper and lower case are treated alike and the result is always written in capitals. Non-letters in the key (digits, symbols) are ignored; a key with no letters at all, or empty text, gives no result. Because the formula is symmetric, entering the ciphertext with the same key gives back the plaintext, though the case of the original is lost. Accented letters such as Ü are not part of the 26-letter alphabet and are passed through untouched.

Worked example

Encrypt Attack at dawn! with the key LEMON. Key letters as numbers: L = 11, E = 4, M = 12, O = 14, N = 13. First letter: A = 0, so 11 − 0 = 11, which is L. Second: t = 19, key E = 4, so 4 − 19 = −15, add 26 to get 11, which is L. Third: t = 19, key M = 12, so 12 − 19 = −7, add 26 to get 19, which is T. Continuing this way, with the spaces and the exclamation mark left alone, the tool outputs LLTOLB ET LNPR!

Try this example →

Common mistakes

  • Expecting Vigenère output. Beaufort subtracts the plaintext from the key, so the same text and key give a different result than Vigenère.
  • Looking for a separate decrypt mode. There is none; paste the ciphertext back in with the same key.
  • Using a key containing digits or symbols and expecting them to count. Only letters are used, so k3y behaves exactly like ky.
  • Expecting the key to restart after every word. It runs continuously across the whole message and skips spaces.
  • Expecting lowercase or accents back after decrypting. The result is uppercase, and letters outside A to Z are not encrypted.

About this calculator

This tool encrypts or decrypts text with the Beaufort cipher, a polyalphabetic cipher closely related to Vigenère but defined as ciphertext = key − plaintext (mod 26) instead of plaintext + key. This makes it reciprocal: running the exact same operation with the same key on the ciphertext recovers the plaintext, so encryption and decryption use one identical process.

Named after Sir Francis Beaufort (though invented by Giovanni Sestri), it was later built into mechanical cipher machines, most famously the Hagelin M-209 of the Second World War. Cryptography students and enthusiasts use this calculator to explore reciprocal ciphers and compare them to Vigenère. Enter your text and a keyword to encrypt or decrypt.

Was this helpful?

You can pick up to 3 reactions.

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators