Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE PYTHON BUT NO PYTHON MODULES cipher from part one #caesar cipher for all 128 ASCII characters #method to encrypt def encrypt(s,key): r=#result string for
USE PYTHON BUT NO PYTHON MODULES
cipher from part one
#caesar cipher for all 128 ASCII characters
#method to encrypt
def encrypt(s,key):
r=""#result string
for i in s:
n = ord(i)
n = (n+key)%128
r=r+chr(n)
return r
#method to decrypt
def decrypt(s,key):
r=""#result string
for i in s:
n = ord(i)
n = (n-key)%128
if(n
n=128-n
r=r+chr(n)
return r
#testing above method
s = input("Enter text to encrypt:")
key =int( input("Enter key:"))
e=encrypt(s,key)
d=decrypt(e,key)
print("Encrypted string:",e)
print("Decrypted sting:",d)
Must provide your own NoWar.dat
all needed is given
remeber to not use any modules
all info is given
Write a python program A that reads a text file called 'NoWar.dat' containing the contents of a letter addressed to Mr. Trump. The program should encrypt the contents of the file using Caesar's cipher from part 1 and then save to a file called 'Trump.dat'. The program should then send the 'Trump.dat' file to another computer running a python program B. Program B should accept the contents of the 'Trump.dat' file and save to the hard drive. Program B should then open the saved Trump.dat' and attempt to break the encryption by trial and error. This involves trying different keys until recognizable text is decoded. Once decoded program B should print the contents of 'NoWar.dat' to the screen. A sample of the screen shot from program B should be included in the submission along with the 'NoWar.dat' file. (Hint: finding recognizable text involves using a keywords that are likely to be present in the original letter to Mr. Trump] [Note: Any program A should be able to work with any program B and vice versa. This allows students to test their programs in a group of at least two persons. However, each student MUST write program A and B]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started