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 a Vigenère cipher uses when decrypting.
How it works
Letters map to 0–25 (A=0 … Z=25). The keyword repeats over the message, advancing only on alphabetic characters:
P = letter index of plaintext (0..25)
K = letter index of key letter (0..25)
encrypt: C = (P - K + 26) mod 26
decrypt: P = (C + K) mod 26
Because encryption subtracts and decryption adds, the two directions are genuinely different — a point that trips people up because the closely named standard Beaufort is its own inverse.
Example and notes
With the key LEMON, the plaintext ATTACKATDAWN enciphers (plain minus key) to
PPHOPQHPRPHA-style ciphertext, and decrypting that same string with LEMON
recovers ATTACKATDAWN. Keep the keyword as long and unpredictable as possible:
short or repetitive keys leak the period to a Kasiski attack and make the message
easy to break.