Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your country is at war and your enemies are using a secretcode to communicate with each other. You have managed to intercepta messsage that reads

Your country is at war and your enemies are using a secretcode to communicate with each other. You have managed to intercepta messsage that reads as follows:
:mmZ\dxZmx]Zpgy
The message is obviously encrypted using the enemy's secretcode. You have just learned that their encryption method is basedupon the ASCii code. Appendix 3 shows the ASCii character set.Individual characters in a string are encoded using this system.For example, the letter "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 andencrypts it as follows:
If(OrigialChar + Key >126) then
EncryptedChar =32+((OriginalChar +Key)-127)
Else
EncrptedChar =(OriginalChar Key)
For example, if the enemy uses Key =10 then the message "Hey"would be encrypted as:
Character ASCii code
--------------------------
H 72
e 101
y 121
Encryped 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 transmetted as "Ro$".
Write a program in C++ that is capable of both encryption of the secret code and decryption of the intercepted message. The ASCII codes for the unencrypted message are limited to the visible ASCII characters.
The secret key used is a number between 1 and 100.
**The code should be organized as follows:
- You would need two functions; both have as inputs the original message along with the encrypted message, and the key.
void encryption (char original [], char secret [], int key);
void decryption (char original [], char secret []);
- The encryption function uses the original message and the key to populate the secret message.
- The decryption function uses the secret message and a combination of all possible keys between 1 and 100 to decode the message. When you try the valid key, the message
will make sense. For all other keys, the message will appear gibberish.
- Both functions can be called inside the main for testing purposes. Generate 2 arrays to accommodate the original and secret messages. Keep the size of the array capped to 1000 characters. The end of each message is designated by a null character \0.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain why you agree or disagree with this statement.

Answered: 1 week ago