Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A crypt-analyst has devised a way to send a message using a method that entirely

ID: 3602719 • Letter: A

Question

A crypt-analyst has devised a way to send a message using a method

that entirely obscures the message from the enemy.

A text of words coming from what appears to be an article written in

an old newspaper, is held by both the sender and the receiver of the

message.

We’ll call this text message:

text.txt

The sender adds a few key words to text.txt (these few key words are

the secret coded message that the sender wants the receiver to

receive). These key words are inserted in such a way as they are not

obvious to the reader (the interceptor) of the message.

We’ll call this text message:

cryptext.txt

By taking the difference between the set of the two messages, the

receiver can filter out all but the intended secret message that (s)he is

supposed to receive.

Write a program that will reveal the intended secret message.

The assignment should be coded in python. The chapter was going over sets, so I assume using sets will be helpful in solving this problem.

Take your result, and sort it so the message is in alphabetical order.

Explanation / Answer

# ENCODE a secret message # Scramble the alphabet, read a secret message, encode it, print scrambled import random def main(): encryption() decryption() def encryption(): encrypt=["*"]*26 # all letters available print(encrypt) print("Alphabet: ", end="") for numbah in range(26): #converts numbah into a letter letter = chr(numbah+65) # converts 0-25 --> 'A' = 'Z' print(letter, end="") #Reminder: find an empty position for that letter to be placed notfound = True while notfound: possible_position = random.randint(0,25) if encrypt[possible_position] == "*": notfound = False encrypt[possible_position] = letter print(" Scrambled: " , end="") for numbah in range(26): print(encrypt[numbah], end="") print(" ") msg=input("Now, please type your secret message to encode: ") print("Your secret message: " + msg) print("Your message encoded: ", end="") # reminder non alphabetic characters should 'float thru' unchanged! for alpha in msg.upper(): if alpha < "A" or alpha > "Z": print(alpha, end="") else: print( encrypt[ ord(alpha) - 65], end="") print(" ") def decryption(): scram_alph = input("Input the scrambled alphabet from the early prog: ") scram_mess = input("Input the scrambled messgae you want decoded: ")
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote