直接加密和解密算法{*******************************************************} { } { Decrypt } { } { bitwise compare of each characters XOR 27 } { } { Return string which after bitwise compare } { } {*******************************************************} function Decrypt(s: string; Key: Integer = 27): string; var i: Integer; begin Result := s; for i := 1 to Length(s) do Result[i] := Chr(Ord(s[i]) xor Key); end;{*******************************************************} { } { Encrypt } { } { Call again Decrypt to back to origin } { } { Return string which after bitwise compare } { } {*******************************************************} function Encrypt(s: string; Key : Integer =27): string; begin Result := Decrypt(s, Key); end;学习下
这是我昨天刚写的,加密算法很简单,要用复杂的算法就要看你想象力了 unit interfacedll;interfacefunction ReadPassword(target:string):string; function WritePassword(source:string):string;implementation function ReadPassword(target:string): string; var s:string[20]; i:byte; begin setlength(s,length(target)); for i:=1 to length(target) do s[i]:=chr(ord(target[i])-ord('a')); result:=s; end;function WritePassword(source:string): string; var t:string[20]; i:byte; begin setlength(t,length(source)); for i:=1 to length(source) do t[i]:=chr(ord(source[i])+ord('a')); result:=t; end;end.
{ }
{ Decrypt }
{ }
{ bitwise compare of each characters XOR 27 }
{ }
{ Return string which after bitwise compare }
{ }
{*******************************************************}
function Decrypt(s: string; Key: Integer = 27): string;
var
i: Integer;
begin
Result := s;
for i := 1 to Length(s) do
Result[i] := Chr(Ord(s[i]) xor Key);
end;{*******************************************************}
{ }
{ Encrypt }
{ }
{ Call again Decrypt to back to origin }
{ }
{ Return string which after bitwise compare }
{ }
{*******************************************************}
function Encrypt(s: string; Key : Integer =27): string;
begin
Result := Decrypt(s, Key);
end;学习下
unit interfacedll;interfacefunction ReadPassword(target:string):string;
function WritePassword(source:string):string;implementation
function ReadPassword(target:string): string;
var
s:string[20];
i:byte;
begin
setlength(s,length(target));
for i:=1 to length(target) do
s[i]:=chr(ord(target[i])-ord('a'));
result:=s;
end;function WritePassword(source:string): string;
var
t:string[20];
i:byte;
begin
setlength(t,length(source));
for i:=1 to length(source) do
t[i]:=chr(ord(source[i])+ord('a'));
result:=t;
end;end.