IN PYTHON: Decrypting with ascii  I have a file called 'dict.txt'. This file contains over 50,000 english words. One word from this file is used as a key (we do not know which one of course). Some have capital letters. I have another file called 'decrypt.txt' which is a file containing a string of numbers i must decrypt using a key found in the 'dict.txt'. This 'decrypt.txt' file message has length of 300.   My question is, since i do not know which word (from the file with the 50,000+ words) is the key I must use to decrypt the other file, how do I write a function that: loops through all possible keys from 'dict.txt' to find the one that decrypts my file 'decrypt.txt' best? Somehow i must count how many 'words' are actual words to determine which key is best and then print my final decrypted message.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

IN PYTHON: Decrypting with ascii 

I have a file called 'dict.txt'. This file contains over 50,000 english words. One word from this file is used as a key (we do not know which one of course). Some have capital letters.

I have another file called 'decrypt.txt' which is a file containing a string of numbers i must decrypt using a key found in the 'dict.txt'. This 'decrypt.txt' file message has length of 300.

 

My question is, since i do not know which word (from the file with the 50,000+ words) is the key I must use to decrypt the other file, how do I write a function that:

loops through all possible keys from 'dict.txt' to find the one that decrypts my file 'decrypt.txt' best? Somehow i must count how many 'words' are actual words to determine which key is best and then print my final decrypted message.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

 i get the error: "ord() expected a character, but string of length 6 found". 

the first 10 lines of the 'dict.txt' file look like this: 

['A', 'a', 'Aachen', 'Aalborg', 'aardvark', 'Aarhus', 'Aaron', 'AB', 'Ab', 'abaci']

the error refers to the first item that contains more than one character 'Aachen'. Does this mean i must somehow convert the file in which it separates all the words first into characters like ['A','a','c','h','e','n']? How would I do this?

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT