Algo sencillo:
Código Delphi
[-]
function Encrypt(const S: String; Key: Word): String;
var
I: integer;
begin
SetLength(Result, length(S));
for I := 1 to Length(S) do
begin
Result[i] := char(byte(S[i]) xor (Key shr 8));
Key := (byte(Result[i]) + Key) * EncryptC1 + EncryptC2;
end;
end;
function Decrypt(const S: String; Key: Word): String;
var
I: integer;
begin
SetLength(Result, length(S));
for I := 1 to Length(S) do
begin
Result[i] := char(byte(S[i]) xor (Key shr 8));
Key := (byte(S[i]) + Key) * EncryptC1 + EncryptC2;
end;
end;
EncryptC1 y
EncryptC2 son dos constantes a elección de cada uno... Y porsupuesto
Key, también a elección de cada uno.