What is the Beaufort cipher?

The Beaufort cipher hides a message with a keyword, so the same letter turns into different letters along the message. It's a close relative of the Vigenère cipher, but it subtracts where the Vigenère cipher adds. It's named after Francis Beaufort, the Irish naval officer who also created the Beaufort wind scale, and its best-known use was in the Hagelin M-209 cipher machine. It's its own inverse: encoding a message twice with the same keyword gives the message back. Today it shows up in geocaches, puzzle hunts and lessons on keyword ciphers.

How a letter is encoded

Think of each letter as its place in the alphabet, counting from 0: A is 0 and Z is 25. The cipher letter is the keyword letter minus the message letter, adding 26 first when the message letter is larger. The keyword is written out again and again under the message, skipping the spaces. With the keyword SUN:

Plain text   Bake a pie
Keyword      SUNS U NSU
Cipher text  Rudo u ykq

B (1) under S (18) becomes 18 − 1 = 17, which is R, and p (15) under N (13) becomes 13 + 26 − 15 = 24, which is y. In other words, the cipher letter counts the steps forward from the message letter to the keyword letter.

Tool description

Start with the Keyword: type it in the field under the Cipher menu. Then paste or write the message itself into the Plain text box to see its Beaufort version in the Cipher text box. The Keyword starts empty, and until it has a letter, any text you type gets "Enter a keyword." instead of a result. Press Insert sample to try See you at the park at noon with the keyword PICNIC. It comes out as Xey pui pp jge nprs np pbup. The Cipher menu switches to the other classical ciphers, such as affine or Playfair. To read a Beaufort message, press the swap button between the boxes, which makes the result the new input, or open the Beaufort Cipher Decoder. Your text stays in your browser.

Examples

Plain text Keyword Cipher text
Bring a kite to the park WINDY Vrfqs w yfku du uwu hiwt
Pancakes at 9 on Sunday SYRUP Dyespiuz uw 9 el Zacpyt
Water the roses tonight GARDEN Kayzn uzw apmjo hdqwhzh
Happy birthday to you CANDLES Vayon dklhgalg zo czj

How the keyword lines up

  • The keyword moves on one letter for each letter of the message and starts over when it runs out. Spaces, digits and punctuation are copied over as they are, and the keyword waits for the next letter. Capitals stay capitals.
  • Only the keyword's letters count, in any case, with accented ones as plain letters: sun flower! works like SUNFLOWER, and crème like CREME.
  • The same letter turns into different ones, like the two e's of See, which become ey in the sample.
  • With the one-letter keyword Z, it's the Atbash cipher: Sunny day becomes Hfmmb wzb either way.

Good to know

  • Accents are dropped in the message too: with PICNIC, Crème brûlée turns into Nrybe byorje and comes back as Creme brulee. Letters the cipher doesn't know, such as ß or Greek letters, are copied as they are.
  • Beaufort and Vigenère messages look alike but don't mix: the Vigenere Cipher Decoder can't read a Beaufort message, even with the right keyword.