Question

In: Computer Science

Please create a Python program that can convert a text string to an encrypted message and...

Please create a Python program that can convert a text string to an encrypted message and convert the encrypted message back to the original message.

  1. Read a string message from your keyboard.
  2. Print the input string.
  3. Convert this message into an encrypted message by using a list element substitution.
  4. Print your encrypted message.
  5. Convert this encrypted message back to the original message by using a list element substitution.
  6. Print your original message.

Important: please use a dictionary data type and append function.

Solutions

Expert Solution

#dictionary have no append method.only list have append method.dictionary have update method

#source code:

import random
small=[chr(i) for i in range(97,123)]
enc=[]
count=0
while(count!=26):
       n=random.randint(97,122)
       if chr(n) not in enc:
           enc.append(chr(n))
           count=count+1
a=input("Enter plain text:")
cipher=""
for i in range(len(a)):
   for j in range(len(small)):
       if(a[i]==small[j]):
           cipher=cipher+enc[j]
print("cipher text:",cipher)

b=input("Enter encryption text:")
plain=""
for i in range(len(b)):
   for j in range(len(enc)):
       if(b[i]==enc[j]):
           plain=plain+small[j]
print("plain text:",plain)

  
  

#output:

#if you have any doubt comment below.....


Related Solutions

A Java program that deciphers each message by building the string. Each line of the text...
A Java program that deciphers each message by building the string. Each line of the text file contains either a word or a command followed by a forward slash and the requirements of the command. A Stack Implementation is needed as. As you read the data from the text file, you need to know if it is a new phrase or command. The commands are: i – an insert followed by the letters, numbers, or symbols that need to be...
In PYTHON: Write a function that receives an encrypted string and decrypts it as follows. The...
In PYTHON: Write a function that receives an encrypted string and decrypts it as follows. The decryption does not change the lowercase letters ‘e’, ‘w’, and ‘l’ (lowercase L). For any other character, we change it to a number using ord(). We then take the number to a power of 19, and then find the remainder after diving by 201. Finally, we take the character corresponding to the number we obtained (using chr()). For example, assume that we receive the...
Using Python, create a program that will act as a number convertor. This program will convert...
Using Python, create a program that will act as a number convertor. This program will convert an input decimal integer into binary and hexadecimal formats. a) Define a main function named numberconvertor(). Inside the main function, write all the logic of your code. [5% marks] b) Looping indefinitely (Hint: use infinite while loop), the program should give the user the 3 options given below and allow the user to select one among them. [15% marks] 1. converting a decimal number...
Text Wrap Problem Write a program in Python that takes an input string and prints it...
Text Wrap Problem Write a program in Python that takes an input string and prints it as multiple lines of text such that no line of text is greater than 13 characters and words are kept whole. For example, the first line of the Gettysburg address: Four score and seven years ago our fathers brought forth upon this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal Becomes: Four score and...
Create this C++ program using classes 1. Create a file text file with a string on...
Create this C++ program using classes 1. Create a file text file with a string on it 2. Check the frecuency of every letter, number and symbol (including caps) 3. Use heapsort to sort the frecuencys found 4. Use huffman code on the letters, symbols or numbers that have frecuencys I created the file, and the frecuency part but i'm having trouble with the huffman and heapsort implementation.
can you please create the code program in PYTHON for me. i want to create array...
can you please create the code program in PYTHON for me. i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this: if N = 16, matrix is [ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4] if N = 64, matrix is [8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the...
Python program. Write a python program that can convert any radix-d (arbitrary base) number to the equivalent radix-e (another arbitrary base) number. Where e and d are members in [2, 16]. Remember, base 16 needs to be calculated as hexadecimal. So, if radix-d is input as a hexadecimal number, it needs to convert and output to desired base. Conversely, if base 16 is the desired output, then the output needs to show a hexadecimal number. Hints: The easiest approach is...
Can you convert this code (Python) to C++ def decrypt(message, key): decryptedText = "" for i...
Can you convert this code (Python) to C++ def decrypt(message, key): decryptedText = "" for i in message: M = ord(i) k = int(key, 16) xor = M ^ k decryptedText += chr(xor) return decryptedText def encrypt(message, key): encryptedText = "" for i in message: M = ord(i) k = int(key, 16) xor = M ^ k encryptedText += chr(xor) return encryptedText # main function userText = input("Enter text: ") userKey = str(input("Enter a key: ")) encryptedMessage = encrypt(userText, userKey)...
Create a message encoder/decoder. PLEASE USE BASIC PYTHON METHODS/FUNCTIONS. The user enters a message that could...
Create a message encoder/decoder. PLEASE USE BASIC PYTHON METHODS/FUNCTIONS. The user enters a message that could only include alphabetic letters and space. There are 26 alphabetic letters. Consider space the 27th letter. The user then enters a shift code that should be an integer between -26 and 26. The application will show the encoded/decoded message based on the shift code entered. If you encode a message, each letter in the message will be moved forward through the alphabet according to...
The assignment is to build a program in Python that can take a string as input...
The assignment is to build a program in Python that can take a string as input and produce a “frequency list” of all of the wordsin the string (see the definition of a word below.)  For the purposes of this assignment, the input strings can be assumed not to contain escape characters (\n, \t, …) and to be readable with a single input() statement. When your program ends, it prints the list of words.  In the output, each line contains of a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT