Re: text encryption
Posted by Annie on February 02, 2005
The easiest but weakest encryption is: add a fixed number to the code of each character.
for i := 1 to Length(S) do S[i] := Char(Ord(S[i] + 8);
for i := 1 to Length(S) do S[i] := Char(Ord(S[i] - 8);
If you have to encrypt short strings like names, this is maybe enough. A bit safer: add or subtract different numbers, depending form the place of the character in the string.
In both cases, make sure that an encrypted character code doesn't exceed 255. Look up in an ASCII table: the code for the highest character that you expect, subtract this from 255, and that's your maximum number that can be added.