Ver Mensaje Individual
  #4  
Antiguo 23-08-2007
Avatar de ArdiIIa
[ArdiIIa] ArdiIIa is offline
Miembro Premium
 
Registrado: nov 2003
Ubicación: Valencia city
Posts: 1.481
Reputación: 22
ArdiIIa Va por buen camino
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;
__________________
Un poco de tu generosidad puede salvar la vida a un niño. ASÍ DE SENCILLO
Responder Con Cita