5341

Description:In this project you will implement a decryption program using the multithreading approach. The program will be given a set of 5 different encrypted English words at the command line. These words are guaranteed to be in the file words_alpha.txt, a large English word list found on https://github.com/dwyl/english-words (Links to an external site.)Links to an external site.. The encryption algorithm used is Ceasar cypher where the amount of shift is unknown – which is what your decryption code has to crack.

Your program has to create 5 threads, where each thread takes up a word to decrypt. Each thread tries different shift amounts. For each shift amount, it shifts the alphabets of its encrypted word, and goes through the word list to see if there is a matching word in the English dictionary. If it finds a match, the thread exits, otherwise it increments the shift amount, shifts the encrypted word and searches again. To take a simple example, lets say one encrypted word is jgnnq, and thread #1 tries shift amounts starting at -1 decreasing by -1 each time. For shift amount -2 it finds a match, that is the word hello in the dictionary, so the thread exits.

A solution is defined as a shift amount (a number between -1 and -25) which maps the encrypted word to a word in the dictionary. Note that each thread exits after finding the first solution (since there may be multiple solutions) or it does not find any solution. Each thread prints a message before exiting (examples shown below). Finally, the main thread must look at the shift amounts of each thread (after all threads exit) to print a concluding message based on three distinct possibilities:
(1) all threads agreed on the same solution
(2) all threads do not agree on the same solution
(3) some threads did not find a solution
Example are shown below for expected outputs from each of those possibilities. Hints: the main thread can do this by inspecting values (shift amounts) stored in a global array by each thread (on amount for each array position).

Requirements: the source code file must be named decrypt.c. The following 3 examples (corresponding to 3 possibilities discussed above) show how the executable (named decrypt) should work on the command line by taking 5 arguments (encrypted words).

Example for possibility #1

./decrypter dbu bwjbo nbo cjse ipstf

Decrypted word found in dictionary: avian, for target word: bwjbo, after applying shift amount of -1
Decrypted word found in dictionary: bird, for target word: cjse, after applying shift amount of -1
Decrypted word found in dictionary: cat, for target word: dbu, after applying shift amount of -1
Decrypted word found in dictionary: man, for target word: nbo, after applying shift amount of -1
Decrypted word found in dictionary: horse, for target word: ipstf, after applying shift amount of -1
Conclusion: All threads agreed on the same solution

Example for possibility #2

./decrypter dbu bwjbo nbo cjse crg

Decrypted word found in dictionary: avian, for target word: bwjbo, after applying shift amount of -1
Decrypted word found in dictionary: bird, for target word: cjse, after applying shift amount of -1
Decrypted word found in dictionary: cat, for target word: dbu, after applying shift amount of -1
Decrypted word found in dictionary: man, for target word: nbo, after applying shift amount of -1
Decrypted word found in dictionary: ape, for target word: crg, after applying shift amount of -2
Conclusion: All threads do not agreed on the same solution

Example for possibility #3

./decrypter dbu bwjbo nbo cjse yza

Decrypted word found in dictionary: avian, for target word: bwjbo, after applying shift amount of -1
Decrypted word found in dictionary: bird, for target word: cjse, after applying shift amount of -1
Decrypted word found in dictionary: cat, for target word: dbu, after applying shift amount of -1
Decrypted word found in dictionary: man, for target word: nbo, after applying shift amount of -1
No decrypted word found in dictionary for: yza
Conclusion: Some threads did not find a solution

Submit the source code file decrypt.c