# DELPHI 自己写的经常用到的加解密函数

function StrDecrypt(s: string; key: word): string;

var
i:byte;
const
fc1=2;
fc2=3;
begin
//result[0]:=s[0];
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)*fc1+fc2;
end;
end;

function StrEncrypt(s: string; key: word): string;
var
i:byte;
const
fc1=2;
fc2=3;
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)*fc1+fc2;
end;
end;

Var
Itm : Array [0..12] of integer;
i,j,k: Integer;
ppp : String;
Const
bb = ’ABCDEFGHIJKL‘;
begin
Pass:=LowerCase(Trim(Pass));
k:=Length(Pass);
j:=1;
ppp:='';
Itm[0]:=0;
if k<12 Then Pass:=Pass+Copy(bb,1,12-k);
For i:=1 To 12 Do Begin
j:=j*2;
Itm[i]:=ord(Pass[i])+k+j;
Itm[0]:=Itm[0]+Itm[i];
End;
Itm[0]:=Itm[0] MOD 12;
For i:=1 To 12 Do
ppp:=ppp+inttostr(Itm[i]);
j:=Itm[0]+1;
k:=length(ppp);
if k mod 2 =0 then k:=k-1;
For i:=1 to 12 Do Begin
if j>k then j:=j-k;
Result:=Result+ppp[j];
j:=j+2;
End;
end;

08-26 126
01-13 1767

07-11 605
05-18 9059
03-04 495
02-05 2765
04-16 2992