Consequently, "Hey" would be transmitted as "Ro$." Write a program Java that decrypts the intercepted message. You only know that the key used is a number between 1 and 100. Your program should try to decode the message using all possible keys between 1 and 100. When you try the valid key, the message will make sense. For all other keys, the message will appear as gibberish. Since there are only 100 keys this would obviously be a pretty crummy encryption system. This Programming Project will require you to explore a bit on your own how to convert from a char to a number, process the number, then convert it back to a char. See Chapter 2 for String methods. You will want to use charAt(). Important: Note that the secret code has a \ so you will need to escape encode it by using \\ if y
11. 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 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 upon the ASCII code (see Appendix 7). Individual characters in a string are encoded using this system. For example, the character ‘A’ is encoded using the number 65 and ‘B’ is encoded using the number 66. Your enemy's secret code takes each letter of the message and encrypts 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 initially be represented as:
Character ASCII code
H 72
e 101
y 121
And "Hey" would be encrypted as:
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
This program requires some knowledge of how to map from ASCII to integers, perform arithmetic, and map back to ASCII.
See the code in Decrypt.java
You might also like to view...
Answer the following statements true (T) or false (F)
1. A function may return more than one item 2. function naming rules follow variable naming rules 3. Every include directive must be followed by using namespace std; 4. the types of parameters are optional in the function declaration 5. the parameter names are mandatory in the function header
The Table row in the query grid indicates the table that the fields in the query are from
Indicate whether the statement is true or false
A moving average is a ________ of averages computed from parts of a data series
A) total B) combination C) chart D) sequence
What is the Smart Brush tool?
What will be an ideal response?