Encrypt and decrypt text using a polyalphabetic substitution cipher
Beaufort Formula: C = (26 - (P - K)) % 26 Find column K, go up to row P, read letter C
The Beaufort cipher is a polyalphabetic substitution cipher that was invented by Sir Francis Beaufort, a British naval officer and hydrographer. It's closely related to the Vigenère cipher but uses a different encryption method and has the special property of being its own inverse—meaning the same algorithm is used for both encryption and decryption.
The Beaufort cipher works as follows:
While the Vigenère cipher uses the formula C = (P + K) mod 26, the Beaufort cipher uses C = (K - P) mod 26, which is mathematically equivalent to C = (26 - (P - K)) mod 26. This reversal creates the reciprocal property where encryption and decryption are the same operation.
The Beaufort cipher can be mathematically represented as follows:
C = (K - P) mod 26
Where:
Since modular arithmetic can produce negative numbers, it's often expressed as:
C = (26 + K - P) mod 26
or simply:
C = (K - P) mod 26
Since the end result is the same with proper modular arithmetic handling.
Plaintext: HELLO
Key: ABCDE
Encryption Process:
Position | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
Plaintext | H (7) | E (4) | L (11) | L (11) | O (14) |
Key | A (0) | B (1) | C (2) | D (3) | E (4) |
Calculation | (0-7) % 26 = 19 | (1-4) % 26 = 23 | (2-11) % 26 = 17 | (3-11) % 26 = 18 | (4-14) % 26 = 16 |
Ciphertext | T | X | R | S | Q |
Result: TXRSQ
The Beaufort Autokey cipher is a variation where only the first character of the key is used as provided, and subsequent key characters are derived from the plaintext itself:
Plaintext: HELLO
Initial Key: K
Generated Key: KHELL (Initial K + plaintext characters H, E, L, L)
Encryption: The same Beaufort process is applied with the generated key
This variation adds complexity because each character's encryption depends on previous plaintext characters, making it harder to break using frequency analysis alone.
Sir Francis Beaufort (1774-1857) is better known for creating the Beaufort wind scale used in weather forecasting than for his cipher. The exact date of his cipher's invention is unclear, but it was during the 19th century.
The cipher was used for naval communications and saw some military use, though less extensively than the related Vigenère cipher. Its reciprocal property (using the same operation for encryption and decryption) made it particularly attractive for field use where simplicity was valuable.
Like other polyalphabetic ciphers of its era, the Beaufort cipher is vulnerable to several attacks:
The Autokey variant offers better security but is still breakable with advanced cryptanalysis techniques.
While the Beaufort cipher is no longer used for serious encryption needs, it retains value in several contexts:
The most interesting aspect of the Beaufort cipher remains its reciprocal nature, which was an innovation at the time of its creation and simplified the encryption/decryption process for manual operations.
The Beaufort cipher represents an interesting chapter in the development of cryptography. Its elegant mathematical properties—particularly its reciprocal nature—made it notable among historical ciphers. While it has been superseded by modern encryption algorithms for security purposes, understanding the Beaufort cipher provides valuable insights into the principles and history of cryptographic design.