You will write a function that can be used to decrypt Dan’s encrypted text. You will be given an open file that contains an encrypted passage from one of the books, and the name of a file containing a wordlist of English words. You need to discover the shift value to use (0-25) in order to decrypt the text. A correct shift value is one that leads to the maximum number of words being found in the English list of words. To find the words in the encrypted text, you must call split(). For a given shift value, convert all letters to lowercase, then try to find each word in the English wordlist. Do not remove any punctuation or symbols from the word: for example, if the word is hello!, then that is the exact string, including exclamation mark, that you should try to find in the English wordlist. Your function should return a string where all letters are in lowercase, and all other characters (newlines, spaces, punctuation, etc.) are retained. Input In each test case, we will call your decrypt function with an open file that contains encrypted text, and the name of a file containing an English wordlist. An encrypted file contains the encrypted text; for example, it might look like this: Q svme pm nmtb smmvtg bpm ijamvkm wn pqa wev niuqtg. An English wordlist has one word per line; here is a small example: abases abash abashed abashes abashing abashment Return Value Using the full English wordlist provided in the starter code, your function would return the following string for the above encrypted text: i knew he felt keenly the absence of his own family.
You will write a function that can be used to decrypt Dan’s encrypted text. You will be given an open file that contains an encrypted passage from one of the books, and the name of a file containing a wordlist of English words. You need to discover the shift value to use (0-25) in order to decrypt the text. A correct shift value is one that leads to the maximum number of words being found in the English list of words.
To find the words in the encrypted text, you must call split(). For a given shift value, convert all letters to lowercase, then try to find each word in the English wordlist. Do not remove any punctuation or symbols from the word: for example, if the word is hello!, then that is the exact string, including exclamation mark, that you should try to find in the English wordlist.
Your function should return a string where all letters are in lowercase, and all other characters (newlines, spaces, punctuation, etc.) are retained.
Input
In each test case, we will call your decrypt function with an open file that contains encrypted text, and the name of a file containing an English wordlist.
An encrypted file contains the encrypted text; for example, it might look like this:
Q svme pm nmtb smmvtg bpm ijamvkm wn pqa wev niuqtg.
An English wordlist has one word per line; here is a small example:
abases abash abashed abashes abashing abashment
Return Value
Using the full English wordlist provided in the starter code, your function would return the following string for the above encrypted text:
i knew he felt keenly the absence of his own family.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images