Program security
01-Oct-95 08:18:29
Sb: #48272-Program security
Fm: Peter Wade 100265,2740
To: Henry Williams 73527,1446
One approach would be to store your strings in encrypted form and decrypt them
just before they are displayed. A simple method which would deter the casual
hacker (but not a determined code breaker) would be to exclusive or each
character in the string with a fixed bit pattern. This garbles the characters
but if you exclusive or the result with the same bit pattern again you get the
original characters back. You would have to write a routine to do this, run all
of your strings through it and save them in a file. Then the program would read
the strings from the file and feed them through the decryption function before
passing them to printf.
A couple of things to bear in mind if you use this method. You probably can't
use the line based file functions like fputs and fgets to read and write the
file becase the encryption may create extra linefeeds in the strings. A
possible method of marking the end of your encrypted strings would be to not
encode the terminating null. If you do this (or if you use any string handling
functions on the encrypted strings) chose a bit pattern for the key which is
not the same as any ascii character you are using, this will make sure you
don't get any extra nulls in the encrypted strings.
Peter Wade
Autopiloting from London, England