The XYZ Republic uses a simple encryption method to send messages between its diplomats. Both sender and receiver have a copy of the file MASKS.TXT which contains the numbers 0 to 255 in random order. Each number is separated from the next by one space; the first few numbers are 28 107 94 119 164 83 168 170 70 ...
To send a message, the sender performs two actions on each character of the message (including all spaces, tabs, newlines, and punctuation):
1. the bits of the character are reversed (e.g. in the message below the first character is 'S' whose ASCII code is 01010011; the reversal produces 11001010).
2. the reversed value (the 11001010) is exclusive ORed with the corresponding (in the example, the first) number in MASKS.TXT, which happens to be 28 or 00011100 in binary. Exclusive ORing 11001010 and 00011100 produces 11010110.
The resulting value is then written as a positive or unsigned number (in this case 214) to the encrypted message file.
Subsequent characters of the message use consecutive numbers from MASKS.TXT for exclusive ORing. If there are more than 256 characters in the message, the numbers in MASKS.TXT are reused from the beginning as often as necessary. Thus, for the message
So, here is a simple "example" on two lines.
the values used from MASKS.TXT are 28 for the 'S', 107 for the 'o', 94 for the comma, 119 for the space and so on. The resulting encrypted file contains the following:
214 157 106 115 178 245 230 12 66 252 156 156 239 184 48 39 93 189 4 198 206 95 41 82 0 68 233 124 42 103 179 1 134 42 188 115 116 151 71 178 76 185 137 173 64
Encrypted files have one space separating each number from the next.
Your program is to prompt for and accept a specification for any file containing an encrypted message, to decrypt the message contained in that file and to display the decrypted message on the screen in its original form. The file MESSAGE1.TXT contains the encrypted message used above as an example.