On the Subject of the Foursquare CM

A machine that knows no bounds when it comes to ciphers.

This cipher uses 2 pages.

Create a key using the keyword on screen 1 page 1 and the Boolean Expression on screen A page 1. Make sure to replace any Js with Is. Rearrange the key into a 5×5 matrix. This will be called Matrix A.

Create a 2nd, 3rd, and 4th matrix by doing the same steps to create Matrix A but with the keyword on screen 2 page 1 and the Boolean Expression on screen B page 1 to create Matrix B, the keyword on screen 3 page 1 and the Boolean Expression on screen C page 1 to create Matrix C, and the keyword on screen 4 page 1 and the Boolean Expression on screen D page 1 to create Matrix D.

Form a 2×2 square of matrices with A in the top left, B in the top right, C in the bottom left, and D in the bottom right.

If there is a number on screen A page 2, take out the letter at that position in the encrypted word. Set aside this letter to be put back in at a later step. Split the encrypted word into pairs of letters. Depending on which instruction is required, apply it to each pair of letters.

If the Submit Button is white, follow the instructions under Encrypt Instructions. Otherwise follow the instructions under Decrypt Instructions.

Encrypt Instructions

  • Find the 1st letter in Matrix A. Find the 2nd letter in Matrix D.
  • Find the intersection between A and D within B to get your 1st letter of the pair.
  • Find the intersection between A and D within C to get your 2nd letter of the pair.

Decrypt Instructions

  • Find the 1st letter in Matrix B. Find the 2nd letter in Matrix C.
  • Find the intersection between B and C within A to get your 1st letter of the pair.
  • Find the intersection between B and C within D to get your 2nd letter of the pair.

Finally, if you took out a letter, insert that letter back into position equal to the number on screen A page 2. If any of the letters on screen 1 page 2 match at the same position as any of the letters of your encrypted word, replace that letter with a J. You should now have an decrypted word.

Example

Encrypted Word: TWSDHGB
Screen 1 Page 2: HSEWGHB
Screen A Page 2: 3
Matrix A: THRILEDABCFGKMNOPQSUVWXYZ
Matrix B: TIDALBCEFGHKMNOPQRSUVWXYZ
Matrix C: HUSABCDEFGIKLMNOPQRTVWXYZ
Matrix D: SLIPERYABCDFGHKMNOQTUVWXZ
Using Decrypt Rules

TWSDHGB + 3 → TWDHGB

THRILTIDAL
EDABCBCEFG
FGKMNHKMNO
OPQSUPQRSU
VWXYZVWXYZ
HUSABSLIPE
CDEFGRYABC
IKLMNDFGHK
OPQRTMNOQT
VWXYZUVWXZ

TW → HU
DH → TI
GB → CE
HUTICE + 3 + S → HUSTICE
HUSTICE + HSEWGHB → JUSTICE
Decrypted Word: JUSTICE