# Keyword Ciphers

A keyword cipher is a way of encoding hidden messages. To use it, the sender and receiver agree on some keyword, and then keep it a secret from everyone else. When the sender has a message to send, she first writes the letters of the keyword followed by every remaining letter of the alphabet in order. To demonstrate, suppose that her keyword is KEYWORD. Then she writes down

$$\text{KEYWORDABCFGHIJLMNPQSTUVXZ}$$

Those letters determine what to substitute for the letters of her actual message:
If her message were, say, SWORDFISH, then the sender could look to see what each letter in her message gets replaced with and then transmit the encoded text PUJNWRBPA.
The great thing about encoding schemes like the keyword cipher is that the encoded text will look like gibberish to anyone who doesn’t understand the code. On the other hand, for someone who does understand the code (like the receiver), recovering the original message is simple: just write out the substitution table and walk each letter back to what it was before the cipher was applied. In the SWORDFISH example, the receiver will know that the S’s became P’s, so the P’s in the encoded text should be decoded as S’s. In the same way, each encoded letter can be decoded until the receiver finds the original message.
The keyword cipher is only secure when only the sender and receiver know the keyword and thus how to encode and decode. Indeed, if some rogue were to figure out the keyword, he would be able to read all future correspondence between those parties.
This is today’s puzzle: trying to figure out the keyword.
If you’re given a long message that uses most of the alphabet, determining the keyword is a simple exercise. For example, if the message were “The quick brown fox jumps over the lazy dog”, and we knew that it was encoded as “Sce ptdog hqmvk amx ftjnr mueq sce iwzy lmb”, then we could just line up each letter with what it turned into to read off the keyword.
Short messages require a bit more problem solving. Suppose I told you that the message “Farces” got encoded as “Btnpzq” – what was the keyword I used to encode it?