Friday, November 7, 2008

Delphi Encrypt - Decrypt Functions

To encrypt / decrypt strings without including "bad" characters (spaces, car return, line feed, tabs, etc)

Code :

function TCrypt.Desencripta(const S: String): String;
var
I: byte;
Key: Word;
ls : string;
begin
Key := 1674;
SetLength(ls,Length(S) div 2);
SetLength(Result,Length(ls));
for I := 1 to Length(ls) do begin
ls[I] := char(StrToInt('$'+ Copy(S, (I*2)-1 , 2)));
end;

for I := 1 to Length(ls) do begin
Result[I] := char(byte(ls[I]) xor (Key shr 8));
Key := (byte(ls[I]) + Key) * C1 + C2;
end;
end;


function TCrypt.Encripta(const S: String): String;
var
I: byte;
Key: Word;
ls : string;
begin
Key := 1674;
SetLength(ls,Length(S));
Result := '';
for I := 1 to Length(S) do begin
ls[I] := char(byte(S[I]) xor (Key shr 8));
Result := Result + IntToHex(byte(ls[I]),2);
Key := (byte(ls[I]) + Key) * C1 + C2;
end;



Download Code
Source : Planet-Source-Code.com

1 Comentário:

JohnCornor said...

A great article for this specific topic.
The deletion of information almost always directs a user to some sense of discontent.
However for the ease of users, experts have designed a an alternative for data corruption challenges.
If a deletion of data scenario is occured, person got to know which application or computer software to use so that he can manage this scenario of data damage.
corrupt pst file

Post a Comment

Latest Comments

About Me

My photo
Makassar, Sulawesi Selatan, Indonesia

Guest Book


ShoutMix chat widget

Script Sense ©Template Blogger Green by Dicas Blogger.

TOPO