Hola:
Simple y funcional.
En el parámetro Key le pasas lo que quieras.... pero para recuperar la clave, tiene que ser el mismo valor. Obvio verdad ??
Código Delphi
[-]
function Encrypt(const S: String; Key: Word): String;
function Decrypt(const S: String; Key: Word): String;
CONST
EncryptC1 = Numero_que_Quieras;
EncryptC2 = Otro_Numero;
function TForm1.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 TForm1.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;