The variant Beaufort cipher is a polyalphabetic substitution cipher closely
related to both Beaufort and Vigenère. Where standard Beaufort enciphers a letter
as key minus plaintext, the variant flips the subtraction to plaintext minus key, which is exactly the operation Vigenère uses when decrypting — making the
two ciphers inverses of each other when using the same key.
How it works
Letters map to 0–25 (A=0, B=1 … Z=25). The keyword repeats over the message, advancing one step only when the next character is alphabetic:
P = plaintext letter index (0..25)
K = key letter index (0..25)
encrypt: C = (P - K + 26) mod 26
decrypt: P = (C + K) mod 26
The +26 before the modulo prevents negative values when P is smaller than K.
Because encryption subtracts and decryption adds, the two operations are genuinely
different — unlike standard Beaufort, where encryption and decryption use the same
formula and the cipher is its own inverse.
Worked example step by step
Encrypt HELLO with the key KEY:
| Position | Plaintext | Key letter | P | K | C = (P−K+26) mod 26 | Ciphertext |
|---|---|---|---|---|---|---|
| 1 | H | K | 7 | 10 | (7−10+26) mod 26 = 23 | X |
| 2 | E | E | 4 | 4 | (4−4+26) mod 26 = 0 | A |
| 3 | L | Y | 11 | 24 | (11−24+26) mod 26 = 13 | N |
| 4 | L | K | 11 | 10 | (11−10+26) mod 26 = 1 | B |
| 5 | O | E | 14 | 4 | (14−4+26) mod 26 = 10 | K |
HELLO → XANBK with key KEY.
To decrypt XANBK with KEY, apply P = (C + K) mod 26 at each position:
X=23+K=10 → 33 mod 26 = 7 = H, and so on — recovering HELLO.
Relationship to Vigenère and standard Beaufort
All three ciphers share the same tabula recta (the 26×26 alphabet-shift grid). The difference is which operands are subtracted:
| Cipher | Formula | Self-inverse? |
|---|---|---|
| Vigenère | C = (P + K) mod 26 | No |
| Standard Beaufort | C = (K − P) mod 26 | Yes |
| Variant Beaufort | C = (P − K) mod 26 | No |
Variant Beaufort encryption is exactly Vigenère decryption, and variant Beaufort decryption is exactly Vigenère encryption. This means if you encrypt a message with Vigenère and then decrypt the ciphertext with variant Beaufort using the same key, you get the original back — and vice versa.
Security considerations
Like all classical polyalphabetic ciphers, the variant Beaufort is vulnerable to cryptanalysis once the key period is determined:
- Kasiski examination finds repeated ciphertext segments to estimate the key length.
- Index of coincidence confirms the key length estimate.
- Frequency analysis per position recovers each key letter from the letter frequencies within that column.
Short or dictionary-word keys are especially weak. Treat this cipher as a puzzle tool or educational demonstration, not a means of protecting real information. For genuine security, use modern authenticated encryption.