Question: Modify the scripts of Projects 1 and 2 to encrypt and decrypt entire files of text. An example of the program interface is shown below:

Modify the scripts of Projects 1 and 2 to encrypt and decrypt entire files of text.

An example of the program interface is shown below:

Enter the input file name: encrypted.txt Enter the output file name: a Enter the distance value: 3

""" File: decrypt.py Decrypts the input strings of lowercase letters and prints the result. The other required input is the distance value. """ code = raw_input("Enter the coded text: ") distance = input("Enter the distance value: ") plainText = '' for ch in code: ordValue = ord(ch) cipherValue = ordValue - distance if cipherValue < ord('a'): cipherValue = ord('z') - (distance - \ (ordValue - ord('a')) - 1) plainText += chr(cipherValue) print plainText """

File: encrpyt.py Encrypts the input string of lowercase letters and prints the result. The other required input is the distance value. """ plainText = input("Enter the output file name: ") distance = int(input("Enter the distance value: ")) code = "" for ch in plainText: ordValue = ord(ch) cipherValue = ordValue + distance if cipherValue > ord('z'): cipherValue = ord('a') + distance - \ ord('z') - ordValue + 1) code += chr(cipherValue) print(code)

These codes need to be edited in order to be correct. We are using the newest version of python which I believe is 3.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!