Home /
Expert Answers /
Other /
modify-the-scripts-of-projects-1-and-2-to-encrypt-and-decrypt-entire-files-of-text-an-example-of-the
(Answered): Modify the scripts of Projects 1 and 2 to encrypt and decrypt entire files of text. An example of t ...
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 decrypt.py encrypt.py | + 1 2 File: decrypt.py 3 Project 4.3 4 5 Decypts a file of encrypted text. and prints 6 the result. The other input is the distance value. 7 III 8 9 code = raw_input("Enter the coded text: ") 10 distance = input("Enter the distance value: ") 11 plainText = 12 for ch in code: 13 ordValue = ord(ch) 14 cipherValue = ordValue - distance 15 if cipherValue < ord('a'): 16 cipherValue = ord('z') - (distance - 1 17 (ordValue - ord('a')) - 1) 18 plainText += chr(cipherValue) 19 print(plainText) 20 + decrypt.py encrypt.py 1 2 File: encrypt.py 3 Project 4.3 4 5 Encypts a text file. The inputs are the names of 6 the input file and the output file and the distance value. 7 The encrypted code is witten to a new file. 8 9 10 plaintext input("Enter a one-word, lowercase message: ") 11 distance = int(input("Enter the distance value: ")) 12 code = III 13 for ch in plaintext: 14 ordValue = ord (ch) 15 cipherValue = ordValue + distance 16 if cipherValue > ord('z'): 17 cipherValue = ord('a') + distance - 18 (ord('z') - ordValue + 1) 19 code += chr(cipherValue) 20 print(code)