Is there any decryption algorithm that uses a dictionary to decrypt the encrypted algorithm?

Ok I was working on setting it up and it says:

The program must be developed and coded in C in order to decrypt a document written in Italian that is encoded using a secret key. The secret key is obtained as a random permutation of all uppercase letters, lowercase letters, numbers, and spaces. As an example, consider the following two lines:

Plain: "ABCDEFGHIJKLMNOPQRSTUVXWYZabcdefghijklmnopqrstuvwxyz0123456789 "
Code:  "BZJ9y0KePWopxYkQlRjhzsaNTFAtM7H6S24fC5mcIgXbnLOq8Uid 3EDv1ruVGw"

      

The secret key only changes the letters, numbers and spaces of the original document, while the rest of the characters remain unchanged. The document is stored in a text file whose length is unknown.

The program must read the document, find the secret key (which is by definition unknown; the above table is just an example, and it is not a key used to prepare the sample files available on the web course) using a suitable decoding algorithm and writing the decoded document into a new text file.

And I know I need to load an English dictionary into the program, but I don't ask (maybe not in this statement, but I have to do it). My question is that although I can make this program using a simple encryption / decryption algorithm, what is the use of loading an English dictionary in our program? So is there any decryption algorithm that uses a dictionary to decrypt the encrypted algorithm? Or can someone tell me which approach or algorithm should I use to solve this problem?

An early reply (as well as an authentic one) will be highly appreciated by you.

Thanks guys.

+1


source to share


3 answers


This is a simple substitution cipher . It can be broken with frequency analysis . The Wikipedia articles explain both concepts in detail. What you need to do:

  • Find the statistical frequency of characters in Italian texts. If you cannot find this publication anywhere, you can build it yourself by analyzing a large corpus of Italian texts.
  • Analyze the frequency of characters in cipher text and compare them with statistical data.


The first Wikipedia article links to a set of tools that implement all of the above. You just need to use and possibly adapt it to your use case.

+8


source


Your cipher is a substitution cipher. That is, he replaces one letter with another.

consider ciphertext

"yjr, 1drv2ry1od1q1 ..."

We can use a dictionary to search for plain text.

Look for punctuation, since a space always follows a comma, you can find a substitution rule for spaces.

which gives you. "yjr, drv2ry od q ..."

Pay attention to the length of the word. Since there are only two 1-letter words in English, q is probably me or a. "yjr" is probably "why", "the", "how", etc.

We try, why with the result

"why, dyv2yw od q ..."



There are no English words with two ys, and ends with w.

So we try "the" and get

", dev2et od q ..."

We conclude that this is a likely answer.

We are now looking for our dictionary for words that start to look like this: e ?? et.

re-rinsing.

That is, find a certain set of words that fit into the available lengths and do not violate the rules for substituting each other.

Personally, I just do the frequency analysis suggested above.

+1


source


Frequency analysis, as both other respondents said, is the way to go and you can use digrams and trigrams to make it that much stronger. Just grab tons of Italian text from the internet and throw it forward! This is really pretty simple programming.

0


source







All Articles