# Beaufort cipher

The Beaufort cipher, created by Sir Francis Beaufort, is a substitution cipher.

Since the encryption and decryption process are identical, the Beaufort cipher is a reciprocal cipher.

The Beaufort cipher uses the same tabula recta as the Vigenère cipher:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
BCDEFGHIJKLMNOPQRSTUVWXYZA
CDEFGHIJKLMNOPQRSTUVWXYZAB
DEFGHIJKLMNOPQRSTUVWXYZABC
EFGHIJKLMNOPQRSTUVWXYZABCD
FGHIJKLMNOPQRSTUVWXYZABCDE
GHIJKLMNOPQRSTUVWXYZABCDEF
HIJKLMNOPQRSTUVWXYZABCDEFG
IJKLMNOPQRSTUVWXYZABCDEFGH
JKLMNOPQRSTUVWXYZABCDEFGHI
KLMNOPQRSTUVWXYZABCDEFGHIJ
LMNOPQRSTUVWXYZABCDEFGHIJK
MNOPQRSTUVWXYZABCDEFGHIJKL
NOPQRSTUVWXYZABCDEFGHIJKLM
OPQRSTUVWXYZABCDEFGHIJKLMN
PQRSTUVWXYZABCDEFGHIJKLMNO
QRSTUVWXYZABCDEFGHIJKLMNOP
RSTUVWXYZABCDEFGHIJKLMNOPQ
STUVWXYZABCDEFGHIJKLMNOPQR
TUVWXYZABCDEFGHIJKLMNOPQRS
UVWXYZABCDEFGHIJKLMNOPQRST
VWXYZABCDEFGHIJKLMNOPQRSTU
WXYZABCDEFGHIJKLMNOPQRSTUV
XYZABCDEFGHIJKLMNOPQRSTUVW
YZABCDEFGHIJKLMNOPQRSTUVWX
ZABCDEFGHIJKLMNOPQRSTUVWXY


Like all symmetrical ciphers, the Beaufort cipher requires both the sender and the recipient to know the same secret key.

For example, suppose that the plaintext to be encrypted is:

   ATTACKATDAWN


And suppose that both the sender and the recipient know the secret key,

   QUICK


The person sending the message repeats the keyword until it matches the length of the plaintext.

Each letter of the plaintext is enciphered using the column that starts with that letter, finding the position of the key letter in that column, and then taking the first letter of the row where that key letter was found. For the second letter of the plaintext, the second letter of the key is used: in column T, the letter U is found in row B. The rest of the plaintext is enciphered in a similar fashion:

   ATTACKATDAWN (plaintext)
QUICKQUICKQU (key)
QBPCIGUPZKUH (ciphertext)


Decryption is performed exactly the same as encryption (it is a reciprocal cipher): Each letter of the ciphertext is decoded using the column that starts with that letter, finding the position of the key letter in that column, and then taking the first letter of the row where that key letter was found. For the second letter of the ciphertext, the second letter of the key is used: in column B, the letter U is found in row T.

## strength and cryptanalysis

The Beaufort cipher is no stronger or weaker than Vigenère; the method to crack it is the same.

...

The Beaufort cipher can also be viewed algebraically. If the letters AZ are taken to be the numbers 0–25, then Beaufort encryption can be written,

$C_i \equiv (K_i - P_i) \mod 26$

and decryption,

$P_i \equiv (K_i - C_i) \mod 26$