project ASCII code program

hello guys i need help with a program please it is due tonight and im not able to do it!:(
CRYPTOGRAPHY




The science of developing secret codes has interested many
people for centuries. Some of the simplest
codes involve replacing a character, or a group of characters with another
character, or group of characters. To
easily decode these messages, the decoder needs the “key” that shows the
replacement characters. In recent times,
computers have been used very successfully to decode many codes that initially
were assumed to be unbreakable.






Suppose a country is at war. A message
from the unfriendly has been intercepted.

It reads:




":mmZ\\dxZmx]Zpgy"




This message is obviously encrypted using a secret
code. The encryption method is based
upon the ASCII code. 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.




The message is encrypted as follows:









If (OriginalChar + Key > 126) then




EncryptedChar = 32 +
((OriginalChar + Key) – 127)




Else




EncryptedChar = (OriginalChar + Key)




For example if the Key = 10 is used, then the message “Hey”
would be encrypted as









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 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 gibberish . Display keys and messages.
.




USE AT LEAST ONE USER DEFINED FUNCTION.

THIS IS THE QUESTION!!:(
What code do you have so far?
Topic archived. No new replies allowed.