Answered step by step
Verified Expert Solution
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:
:mmZdxZmxZpgy
The message is obviously encrypted using the enemy's secretcode You have just learned that their encryption method is basedupon the ASCii code. Appendix 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 and Bis encoded using the number
Your enemy's secret code takes each letter of the message andencrypts it as follows:
IfOrigialChar Key then
EncryptedChar OriginalChar Key
Else
EncrptedChar OriginalChar Key
For example, if the enemy uses Key then the message "Hey"would be encrypted as:
Character ASCii code
H
e
y
Encryped H R in ASCii
Encrypted e o in ASCii
Encrypted y $ 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 and
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 and 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 arrays to accommodate the original and secret messages. Keep the size of the array capped to characters. The end of each message is designated by a null character
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started