Decoding a Playfair Code with Matlab: Tips and Tricks

In summary, the person is looking for help decoding a Playfair cipher and is having trouble programming in matlab.
  • #1
Impo
17
0
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,
Impo
 
Physics news on Phys.org
  • #2
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.
 
  • #3
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?

Thanks!
 

FAQ: Decoding a Playfair Code with Matlab: Tips and Tricks

How do I input a Playfair code into Matlab?

In order to input a Playfair code into Matlab, you will need to first create a text file containing the code. Then, you can use the "load" function in Matlab to load the code into a variable. Alternatively, you can also manually enter the code into a variable using the "input" function.

How do I decode a Playfair code using Matlab?

To decode a Playfair code using Matlab, you will first need to create a function that implements the Playfair algorithm. This function should take in the encoded message and the Playfair code as inputs and return the decoded message. Then, you can call this function in your main script to decode the Playfair code.

Can I decode a Playfair code without using a function in Matlab?

Yes, it is possible to decode a Playfair code without using a function in Matlab. However, using a function can make the code more organized and easier to modify in the future. It is recommended to use a function to implement the Playfair algorithm.

Is there any built-in function in Matlab for decoding Playfair codes?

No, there is no built-in function in Matlab specifically for decoding Playfair codes. You will need to create your own function or use a pre-existing function from an external source.

How can I improve the efficiency of my Playfair code decoding in Matlab?

One way to improve the efficiency of your Playfair code decoding in Matlab is to optimize your code by reducing unnecessary loops and using efficient data structures. You can also try parallel computing in Matlab to speed up the process. Additionally, regularly testing and debugging your code can help identify any areas for improvement.

Similar threads

Replies
32
Views
3K
Replies
3
Views
2K
Replies
6
Views
4K
Replies
12
Views
3K
Replies
3
Views
6K
Back
Top