Sams Teach Yourself C in 21 Days

(singke) #1
Here is an example of a secret message:
Ymnx%nx%f%xjhwjy%rjxxflj&
Decoded, this message says:
This is a secret message!
This program codes and decodes the information by simply adding and subtracting a
value from the characters being entered. This is a pretty easy code to crack. You can
make it even harder to crack by replacing lines 91 and 97 with the following:
ch = ch ^ val;
Suffice it to say that the ^is a binary math operator that modifies the character at the bit
level. It will make your secret messages even more secret!
If you want to give the program to a number of different people, you might want to add a
third parameter to the command line. This parameter would accept the value for val. The
variablevalstores the value to be used to encode or decode.

308 Type & Run 4

20 448201x-T&R4 8/13/02 11:12 AM Page 308

Free download pdf