Welcome to our community

Be a part of something great, join today!

Number Theory Decoding


New member
Apr 2, 2013
Hi all,

I hope my post is in the right section. I need some help with decoding a Playfair code.

I only have the ciphertext which is 22 lines long. What's the best way to do this? I red that I have to do some frequency analysis of the English bigrams which I did. There's one combination which has the highest frequency. I changed this combination by 'th', but now I have three combinations with the same frequency. How can I solve this problem?

(I'm working with matlab)

Is there a better way?

Many thanks,
Regards from Italy,


Indicium Physicus
Staff member
Jan 26, 2012
Two comments:

1. Try all six possibilities, and see if anything jumps out at you.

2. This might prove useful, from the wiki on Playfair ciphers:

Like most classical ciphers, the Playfair cipher can be easily cracked if there is enough text. Obtaining the key is relatively straightforward if both plaintext and ciphertext are known. When only the ciphertext is known, brute force cryptanalysis of the cipher involves searching through the key space for matches between the frequency of occurrence of digrams (pairs of letters) and the known frequency of occurrence of digrams in the assumed language of the original message.

Cryptanalysis of Playfair is similar to that of four-square and two-square ciphers, though the relative simplicity of the Playfair system makes identifying candidate plaintext strings easier. Most notably, a Playfair digraph and its reverse (e.g. AB and BA) will decrypt to the same letter pattern in the plaintext (e.g. RE and ER). In English, there are many words which contain these reversed digraphs such as REceivER and DEpartED. Identifying nearby reversed digraphs in the ciphertext and matching the pattern to a list of known plaintext words containing the pattern is an easy way to generate possible plaintext strings with which to begin constructing the key.


New member
Apr 2, 2013
Thanks for the answer! I found a method now to solve it (it's called the SA algoritm), I only have some troubles with programming in matlab. First I need to write a code for the encryption of playfair, the problem is I have no idea how to implement a code for the 5x5 matrix with the key word in it.

The idea is I want to make a function, say 'PlayfairEncrypter' with two input variables: the plaintext and the keyword and with the ciphertext as the output. I have to make a 5x5 matrix with the key word in it and the other letters of the alphabet in alphabetic order. Can someone help me with this code?