K
kmwap
Unregistered / Unconfirmed
GUEST, unregistred user!
哪位高手能将这一DELPHI函数转为ASP的,200分相赠.
Function Encrypt(Src:String; Key:String):string;
var
idx :integer;
KeyLen :Integer;
KeyPos :Integer;
offset :Integer;
dest :string;
SrcPos :Integer;
SrcAsc :Integer;
TmpSrcAsc :Integer;
Range :Integer;
begin
dest :='';
if Src<>'' then
try
KeyLen:=Length(Key);
KeyPos:=0;
SrcPos:=0;
SrcAsc:=0;
Range:=256;
Randomize;
offset:=Random(Range);
dest:=format('%1.2x',[offset]);
for SrcPos := 1 to Length(Src) do
begin
SrcAsc:=(Ord(Src[SrcPos]) + offset) MOD 255;
if KeyPos < KeyLen then KeyPos:= KeyPos + 1 else KeyPos:=1;
SrcAsc:= SrcAsc xor Ord(Key[KeyPos]);
dest:=dest + format('%1.2x',[SrcAsc]);
offset:=SrcAsc;
end;
except
end;
Result:=Dest;
end;
Function Encrypt(Src:String; Key:String):string;
var
idx :integer;
KeyLen :Integer;
KeyPos :Integer;
offset :Integer;
dest :string;
SrcPos :Integer;
SrcAsc :Integer;
TmpSrcAsc :Integer;
Range :Integer;
begin
dest :='';
if Src<>'' then
try
KeyLen:=Length(Key);
KeyPos:=0;
SrcPos:=0;
SrcAsc:=0;
Range:=256;
Randomize;
offset:=Random(Range);
dest:=format('%1.2x',[offset]);
for SrcPos := 1 to Length(Src) do
begin
SrcAsc:=(Ord(Src[SrcPos]) + offset) MOD 255;
if KeyPos < KeyLen then KeyPos:= KeyPos + 1 else KeyPos:=1;
SrcAsc:= SrcAsc xor Ord(Key[KeyPos]);
dest:=dest + format('%1.2x',[SrcAsc]);
offset:=SrcAsc;
end;
except
end;
Result:=Dest;
end;