Related to C++ (NOTE: THIS QUESTION HAS THREE COMPONENTS...I HAVE ALREADY COME UP WITH A SOLUTION FOR THE FIRST PART BUT I NEED HELP WITH THE OTHER 2) PART 1 (HW 23): 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: :mmZdxZmx]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. Appendix 3 of your book shows the ACII 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 and encrypts it as follows: If(OriginalChar + Key > 126) then EncryptedChar = 32 + ((OriginalChar + Key ) - 127) else EncryptedChar = (OriginalChar + Key) For example, if the enemy used Key = 10 then the message "Hey" would be encrypted as: Character ASCII Code H 72 e 101 y 121 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. For all other keys the message will appear as gibberish. PART 2 (HW 24): From HW#23 you should have functions that can decode a character given a key and that candecrypt a word given a string of encrypted characters. Then of course a main program thatallows you to enter an encrypted word and a key, calls decrypt, and displays the resulting text.The human user views the text to see if the guessed key was correct.Now for HW#24 we want to automate searching for the key. Extend the HW#24 solution bywriting a new function, lets call it word_check, that will accept as input an array of charactersthat is a “decoded” word (i.e. a word that decrypt produces for a given key) and compares thatword with English words contained in the words.txt file (words.txt can be downloaded from theclass web page).The word_check routine will do these things:open the words.txt file check for file open failure, exit program if failure occursrepeatedly read a word from the file compare that word with the decoded word until a match is found or the end of file is reachedclose the file.with a return statement, return an integer value that is a count of how many words were compared. If a match was found, return this count as a negative number but if a match was not found return the count as positive.
Then in the main program create a loop that will sequence through keys 1 to 95 calling decryptfollowed by word_check until a match is found (or all keys have been tried and a match fails).Display the decoded message (i.e. the decoded word), key number that was found to decode themessage, and the value returned from word_check which will be the position within the word.txtfile where the matching word was found.Note that HW#24 will not handle messages that have multiple words in them such as the one inthe original problem definition nor does it need to. PART 3 (HW 25): Extend the program to allow for multi-word messages and handle uppercase characters in words. It does not need to handle words with numbers nor punctuation characters including things like () or [] etc. Like part 2, it will display the decoded message and the key used for decoding. And of course it will need to have the words.txt file accessible (words.txt file here: http://people.wallawalla.edu/~larry.aamodt/cptr141/words.txt).
Get Free Quote!
371 Experts Online