Friday, February 17, 2017

Using Codes in Your Games: The Playfair Cipher

Today I would like to talk about using codes in you role-playing games.  I once read some advice that said giving players a code to solve during the game would bog everything down.  Players would whine that they would just want to make a skill roll rather than try to decode some jumble that you prepared for them.  I agree with 70% of this statement.  In my opinion the appropriate place for codes in you games is in between sessions.  Send your players a coded message a few days before game night.  This will pique their interest and get them psyched up for the session.  I even have a code that I would suggest that you use.  It is called the Playfair Cipher.

I first learned of the Playfair Cipher when I read the book Maelstrom by Paul Preuss.  This is the second book in the Venus Prime series, which is a set of science fiction stories based on concepts created by Arthur C. Clarke.  The main character in the Venus Prime books is a woman who is enhanced with cybernetics and uses her powers to solve mysteries.  The author included a scene where two of the characters exchange a message using a Playfair Cipher.  Preuss even includes an explanation of the Playfair Cipher in the back of the book.

The Playfair Cipher involves picking a five letter word as a key word,  This key word is then used to arrange the alphabet into a grid.  The message is then turned into code using the grid.  To code and decode the message, all you need is the key word.  I think that this is an apt code to use with your role-playing group because it is fun to send then a message with a key word themed to your game.  Also, there are websites that will code and decode Playfair Cipher messages for you, so if your players are too busy with school/work/family life they can pop the key word and message into the site and have it decoded for them.

So how does the Playfair Cipher work?  First, you need a five letter key word.  I am going to encode a message for a Delta Green game so I will use the word DELTA as my key word.  You will then make a 5x5 grid of the alphabet with your key word being the first row.

D  E  L  T  A

DELTA is the first row for our grid.  You then write the remaining letters row by row, omitting letters that are already in the key word.  Standard practice for Playfair Ciphers is to combine I and J into one letter.  So the next line of the grid would look like so:

D  E  L  T  A
B  C  F  G  H

Notice that D and E are left out of the second row since they are already in the first row. You would continue in this fashion until you write the entire alphabet in your 5x5 grid.

D  E  L  T  A
B  C  F  G  H
I  K  M  N  O
P  Q  R  S  U
V  W  X  Y  Z

Notice that the J is missing.  That is because I and J occupy the same place and often people will put IJ in that spot on the grid.

Now you need your message that you will code.  My message will be "Innsmouth has fallen".  First, take the message and divide it into blocks of two letters.  There are a few rules you must follow.  If a block of two letters contain the same letter, then they need to be separated by an X.  Also, if the message contains an uneven number of letters place an X at the end.  Therefore, our message -

innsmouthhasfallen

would be broken down into:

/in/ /ns/ /mo/ /ut/ /hx/ /ha/ /sf/ /al/ /le/ /nx/

The crux of the Playfair Cipher is that every combination of two letters has a corresponding combination located in the grid.  Therefore, if you can recreate the grid then you can decode the message that was encoded using that grid.  Here are the rules for encoding messages with a Playfair Cipher.  If the two letters are located in the same row of the grid, then substitute each letter for the letter to its right.  For example, the first block "in" would become "ko".  If the letters are located in the same column, then the letters are substituted for the letters in the spot below.  The next block, "ns", would become "sy".  The letters "mo" would become "ni", as the grid wraps around and "i" is considered to the right of "o".

The next rule is a little tricky.  Let's say two letters don't fall in the same row or column.  Let's look at the third block of letters, "ut".  The U and T form the corner of a rectangle in the grid.

*  *  *  T  A
*  *  *  G  H
*  *  *  N  O
*  *  *  S  U
*  *  *  *  *

The "u" and "t" are replaced with the letters in the corresponding corner of the rectangle that is created.  Thus, the "u" would become "s" and the "t" becomes "a".  So "ut" becomes "sa".  The next block in the message, "hx" would become "fz".

*  *  *  *  *
*  *  F  G  H
*  *  M  N  O
*  *  R  S  U
*  *  X  Y  Z


Continuing with these rules, the letters in the message encode to:

/ko/ /sy/ /ni/ /sa/ /fz/ /oh/ /rg/ /dt/ /tl/ /my/

Then you just string them together and you have your encoded message:

kosynisafzohrgdttlmy

To decode the message you take the key word DELTA and make the grid.  Use the rules for encoding in reverse (i.e. letters in the same row move to the left, letters in the same column move up, etc.) and you can decode the message.  Ignore extraneous Xs and you have your decoded message.

I know what you are thinking.  Your players are too lazy to go through all that trouble.  My answer to that is that there are handy websites that will decode the message for them.  The one that I like is rumkin.com/tools/cipher/playfair.  Head on over to the site, change the encrypt setting to decrypt, type in DELTA for the alphabet key, and paste in the coded message where it says "your message".  The site also has a nice explanation for using the Playfair Cipher in case mine was too confusing.

Teach your players the Playfair Cipher at your next session.  Tell them that you will be emailing them a coded message before the next game session.  Send them this message:


kosynisafzohrgdttlmy

- DELTA

Tell them that if they greet their handler with the correct message in-game they will get a special weapon/item.  The feeling of intrigue will help build excitement before the game.  

I would practice doing a few ciphers on your own.  I had to do two or three to get the hang of them.  Use the rumkin website to check your work.  Then use coded messages in your campaign!