Código
Function Crypt(Opcao : String; Dados : String): String;
var
I : Integer;
Key : Word;
Res : String;
const
C1 = 33598;
C2 = 24219;
Chave = 16854;
begin
Key := Chave;
for I := 1 to length(Dados) do
begin
Res := Res + Char(Byte(Dados[I]) xor (Key shr 8));
if Opcao = 'CRYPT' then
Key := (Byte(Res[I]) + Chave) * C1 + C2;
if Opcao = 'DECRYPT' then
Key := (Byte(Dados[I]) + Chave) * C1 + C2;
end;
Result := Res;
end;
{Para criptografar uma string:}
Edit2.Text := Crypt('CRYPT',Edit3.Text);
{Para descriptografar uma string criptografada por esta função:}
Edit1.Text := Crypt('DECRYPT',Edit2.Text);
Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009