Beaufort cipher
Encrypt and decrypt with the Beaufort cipher, compare it with the variant Beaufort and Vigenère ciphers, and inspect the aligned key stream.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Letters processed: 0
Spaces, digits, punctuation and CJK characters are untouched and do not consume key letters.
C = K − P (mod 26)Beaufort is an involution: the same pass both encrypts and decrypts.
Keyed alphabet
Key letters come first in order of first appearance, then the remaining letters A–Z
Key alignment
Enter some text to see which key letter and shift each letter uses
What this tool does
- Compare three related algorithms side by side — Beaufort, variant Beaufort and Vigenère — while working through a classical cipher exercise or a puzzle.
- Align key letters against every plaintext letter to check the shift value position by position when your result disagrees with someone else’s.
- Use it where you want something reversible but do not need real cryptography: internal codewords, puzzle answers, a note a casual reader should not skim.
- Teach the weaknesses of the Vigenère family — periodic keys and leaked letter frequency — with the alignment table right there.
Example
Input
Plain text DEFENDTHEEASTWALLOFTHECASTLE, key FORTIFICATION, algorithm Beaufort, direction encrypt
Output
CKMPVCPVWPIWUJOGIUAPVWRIWUUK
This is the classic worked example. Beaufort is C = K − P (mod 26), and because it is an involution you get the plaintext back by running the ciphertext through the same operation with the same key.
Frequently asked questions
What exactly separates Beaufort from Vigenère?
The formula: Beaufort is C = K − P, Vigenère is C = P + K and variant Beaufort is C = P − K, all modulo 26 — the difference is who is subtracted from whom. Beaufort has a handy property: it is an involution, so encryption and decryption are the same pass and feeding the ciphertext back returns the plaintext. Vigenère and variant Beaufort are mutual inverses, so decryption switches algorithm.
Do spaces, digits or non-Latin text take part?
No. Only A–Z are processed; spaces, punctuation, digits and CJK characters pass through unchanged and do not consume a key letter — the key only advances on letters. That means you can keep the original punctuation in the ciphertext and the key stream still lines up when you decrypt.
Is letter case preserved?
Yes. A lowercase letter produces a lowercase letter and an uppercase one produces uppercase; case never affects the arithmetic. Note that decrypted casing follows the ciphertext pattern rather than the original plaintext, because case information was never carried through the cipher.
Does it matter if the key has repeated letters?
Not for correctness — the key just repeats cyclically, and duplicates only shorten the period. A short period is far easier to break with frequency analysis such as the Kasiski examination, so even for puzzles pick a long, irregular keyword like the FORTIFICATION used in the example.
Can I use this to protect real data?
No. The Vigenère family was broken back in the 19th century and a modern computer brute-forces it instantly. It is only for puzzles, teaching and keeping something from being read at a glance; use real modern encryption such as AES for actual secrets. All computation happens locally in your browser.
Keywords:beaufortbeaufort ciphervariant beaufortvigenere维吉尼亚博福特密码classical cipher古典密码加密解密