Your country is at war and your enemies are using a secret code tocommunicate with each other. You have managed to intercept amessage that reads as follows: :mmZ\dxZmx]Zpgy The message is obviously encrypted using the enemy's secret code.You have just learned that their encryption method is based uponthe ASCII code. Individual characters in a string are encoded usingthis system. For example, the letter "A" is encoded using thenumber 65 and "B" is encoded using the number 66, and so on (Googlefor the ASCII table for conversion.) Your enemy's secret code takes each letter of the message andencrypts it as follows: If (OriginalChar + Key > 126) then EncryptedChar = 32 + ((OriginalChar + Key) - 127) Else EncryptedChar = (OriginalChar + Key) For example, if the enemy uses Key = 10 then the message "Hey"would be encrypted as: ASCII Conversion H --> 72 e --> 101 y --> 121 Encrypted H = (72 + 10) = 82 = R in ASCII Encrypted e = (101 + 10) = 111 = o in ASCII Encrypted y = 32 + ((121 + 10) -127) = 36 = $ in ASCII Consequently, "Hey" would be transmitted as "Ro$." Write a program that decrypts the intercepted message. You onlyknow that the key used is a number between 1 and 100. Your programshould try to decode the message using all possible keys between 1and 100. When you try the valid key, the message will make sense.For all other keys, the message will appear as gibberish
Your country is at war and your enemies are using a secret code tocommunicate with each other. You have managed to intercept amessage that reads as follows:
:mmZ\dxZmx]Zpgy
The message is obviously encrypted using the enemy's secret code.You have just learned that their encryption method is based uponthe ASCII code. Individual characters in a string are encoded usingthis system. For example, the letter "A" is encoded using thenumber 65 and "B" is encoded using the number 66, and so on (Googlefor the ASCII table for conversion.)
Your enemy's secret code takes each letter of the message andencrypts it as follows:
If (OriginalChar + Key > 126) then
EncryptedChar = 32 + ((OriginalChar + Key) - 127)
Else
EncryptedChar = (OriginalChar + Key)
For example, if the enemy uses Key = 10 then the message "Hey"would be encrypted as:
ASCII Conversion
H --> 72
e --> 101
y --> 121
Encrypted H = (72 + 10) = 82 = R in ASCII
Encrypted e = (101 + 10) = 111 = o in ASCII
Encrypted y = 32 + ((121 + 10) -127) = 36 = $ in ASCII
Consequently, "Hey" would be transmitted as "Ro$."
Write a program that decrypts the intercepted message. You onlyknow that the key used is a number between 1 and 100. Your programshould try to decode the message using all possible keys between 1and 100. When you try the valid key, the message will make sense.For all other keys, the message will appear as gibberish.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Write an assembly
from 1 to 49. Prints one number per line.