Question: Write a program to encrypt a message using a specified base for encoding. The program should include the following two functions: def encrypt _ message

Write a program to encrypt a message using a specified base for encoding. The program should
include the following two functions:
def encrypt_message (message, base)
The encrypt_message function should take a message as input and a base (from 2 to
9) from the user in the input box.
For simplicity, only consider accepting characters A-Z, a-z, and space. Let uppercase
letters A-Z correspond to decimals 0-25, lowercase letters a-z correspond to decimals 26-
51, space correspond to 52.
The output should be the encrypted message, for example:
encrypt_message(I am on my way,2)
should return the following output:
001000110100011010100110110100101000100111110100100110110010110100110000011010110010
decrypt_message(encrypted_message, base).
The decrypt_message function should take the encrypted message and the base
(from 2 to 9) that was used during encryption.
The encrypted message consists of numbers in the given base, which correspond to the
original characters.
The function should reverse the encryption process by converting the values back to their
respective characters and returning the decrypted message.
Requirements:
1. Your program should print the encrypted message without any space
2. Your program should detect the space when scanning the encrypted message for
decryption.

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 Programming Questions!