python Programming Exercise 4.7
Write a script that decrypts a message coded by the method used in Project 6.
Method used in project 6:
Add 1 to each character’s numeric ASCII value.
Convert it to a bit string.
Shift the bits of this string one place to the left.
A single-space character in the encrypted string separates the resulting bit strings.
An example of the program input and output is shown below:
Enter the coded text: 0010011 1001101 1011011 1011011 1100001 000011 1110001 1100001 1100111 1011011 1001011 000101 Hello world!
Provided code is done as per your requirements.
Code Image:
Sample Output:
Code to Copy:
#Implementation of bits2String method
def bits2String(b=''):
return chr(int(b,2) - 1)
#Implementation of shift method
def shift(n=''):
temp = list(n)
new = (temp[-1:] + temp[0:-1])
ret = ''
for i in new:
ret += i
return ret
#Get the input from user
coded = input('Enter the coded text:')
#split the code
process = coded.split()
decoded = ''
for q in process:
decoded += bits2String(shift(q))
#Display the decoded message
print(decoded)
python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used...
Programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 bits = input("Enter bit string: ") bits = bits[1:] + bits[0] print ("Result:", bits) to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting...
Your country is at war and your enemies are using a secret code to communicate with each other.You have managed to intercept a message that reads asfollows::mmZdxZmx]ZpgyThe message is obviously encrypted using the enemy's secret code.You have just learned that their encryption method is based upon the ASCII code.Appendix 3 of your book shows the ACII character set.Individual characters in a string are encoded using this system. For example, the letter "A" isencoded using the number 65 and "B" is...
C++ please Programming Assignment #6 Help Me Find The Secret Message Description: This assignment will require that you read in an encrypted message from a file, decode the message, and then output the message to a file. The encryption method being used on the file is called a shift cipher (Info Here). I will provide you with a sample encrypted message, the offset, and the decrypted message for testing. For this project I will provide you main.cpp, ShiftCipher.h, and ShiftCipher.cpp....