Reply To: !
A Tale of 2 Secrets › Forums › T.E.M.P.E.S.T. › ! › Reply To: !
@Gen_ruikt
Playfair is a digraph substitution cipher, so everything happens two letters at a time rather than one. The method is completely symmetric so the encryption and decryption rules are the same except for the direction you move in the grid.
To simplify the explanation of the decryption, let’s assume we know the grid used for encryption. Courtesy of Madness’ cipher challenge archive, here’s an example from 2001 Challenge 5.
Section of ciphertext: NZTFM YKDID MYLCY NSGZ
The 5×5 polybius square used is:
G O L D E
N J U B I
A C F H K
M P Q R S
T V W X Y
Since the alphabet has 26 letters but the grid has only 25 spaces, one letter must be removed or merged. Here, Z is omitted, so all Z’s in the ciphertext must be replaced with Y’s. Some variants merge I/J instead. Doesn’t matter which letter you omit, the important thing is consistency
To decrypt, we first the ciphertext in pairs:
NZ TF MY KD ID MY LC YN SG Z…
Then for each pair, apply exactly one of the three rules:
both letters on the same row – move one step to the left for decryption (encryption moves right, so decryption moves left).
Both letters are in the same column – move one step up for decryption (encryption moves down, so decryption moves up).
Both letters form the corners of a rectangle – swap them by taking the letters in the same row but the other column.
So taking our first pair: NZ, notice its (row, col) position:
N is (2,1) and Z is replaced with a Y, which is in (5,5).
This forms a rectangle, so we take the letters which are in the same row but other column, namely the positions (2,5) and (5,1), corresponding to: “IT”
NZ -> IT
The next pair: TF
T is (5,1) and F is (3,3)
This forms a rectangle again, so we take the letters in positions (5,3) and (3,1), corresponding to “WA”
TF -> WA
… and so on…
MY -> ST
KD -> HE
ID -> BE
…
once you do this, the start of the plaintext string should read: “ITWASTHEBESTOFTIMES”
Does this make sense? Do ask if something still feels confusing or if you’re unsure about it.
In terms of implementing an attack to break this ciphertext, I’d suggest you look at hill climbing or simulated annealing in Madness book