hey, guys, how are you doing? i wish everybody is working well, anyway, actually i am a new one, i just want your help guys if you have some experience, in fact, i am a novice i don't know how to make a program in C++. I have no idea, the lecturer has given me this question as my assignement but i really have no idea how to solve it and i don't know how can i post a question in the right way, i hope i can get your responses as soon as possible..thank you, i really appreciate.
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.
Individual characters in a string are encoded using this system. For example,
TCP1231 Computer Programming 1 Assignment 1
Page 3 of 6
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 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 be
encrypted as:
Character ASCII code
H
e
y
72
101
102
Encrypted H = (72 + 10) = 82 = R in ASCII
Encrypted e = (101 + 10) = 111 = o in ASCII
Encrypted y = ((121 + 10) - 127) = 36 = $ in ASCII
Consequently, “Hey” would be transmitted as “Ro$”.
Write a program 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.
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.
Individual characters in a string are encoded using this system. For example,
TCP1231 Computer Programming 1 Assignment 1
Page 3 of 6
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 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 be
encrypted as:
Character ASCII code
H
e
y
72
101
102
Encrypted H = (72 + 10) = 82 = R in ASCII
Encrypted e = (101 + 10) = 111 = o in ASCII
Encrypted y = ((121 + 10) - 127) = 36 = $ in ASCII
Consequently, “Hey” would be transmitted as “Ro$”.
Write a program 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.
Comment