Time to play fair
You receive a message from your sister back on Earth. Just as a couple of years ago, you still communicate with each other using a private cipher - for a little bit of nerdy fun between siblings. Recently you both agreed to switch to using a Playfair cipher, so that’s what you are going to have to figure out in order to read the message.
Since there are a few ways of implementing playfair, you remember the two of you agreed to the following stipulations:
- Replace any and all occurrences of
jwith the letteri. - For words of odd length, append an
x(unless the last letter is alreadyx, in which case use aq).
Example
Consider this example playfair grid, created using the encryption key of helloworld and the phrase to decode of wp nehslv ewgw.
h e l o w
r d a b c
f g i k m
n p q s t
u v x y z
- Notice that repeat occurrences of letters have been ignored when created the grid (only the first
landoappear). - The rest of the alphabet has been added, ignoring letters used by the cipher key and the letter
j. - Break each word of the phrase into letter pairs:
wp,ne hs lvandew gw. wpappears on different rows and columns in the grid. That meanswis replaced by the letter at the same row aswbut the column ofp, which is the lettere. Likewise,pis replaced by the letter at the same row aspbut the column ofw, which is the lettert.- The pairs
ne,hs,lv, andgwall appear in different rows and columns to their paired letter, so the same method applies. - The pair
ewappear in the same row to each other, so in that case, theeis replaced by the letter immediately to the left which ish, and thewis also replaced with the letter immediately to the left which iso(wrap around if required. For instancehwould be decoded withwin the above example). A similar process applies if a pair of letters appear in the same column, you decode with the letter immediately above each letter.
The above phrase decodes to et phonex home. The x in phonex appears as the x was added to ensure all words have an even number of letters. It is one of the quirks of the playfair algorithm.
Your task
Obtain your decryption key and message to decode from your input data. The decoded message is your answer.