冬
冬月
Unregistered / Unconfirmed
GUEST, unregistred user!
function DecodeA(pInChar;pOutChar;Size:Integer):Integer;
var
i1,i2,i3,i4:byte;
i,iptr,optr:integer;
key1,key2:byte;
begin
key1:=$ac;
key2:=$3c;
iptr:=0;
optr:=0;
for i:=0 to (Size div 4)-1 do
begin
//依次取出4个字符
i1:=byte(pIn[iptr])-key2;
Inc(iptr);
i2:=byte(pIn[iptr])-key2;
Inc(iptr);
i3:=byte(pIn[iptr])-key2;
Inc(iptr);
i4:=byte(pIn[iptr])-key2;
Inc(iptr);
//生成第一个明文字符
pOut[optr]:=chr((i1 and 3) or (((i1 and $3c) shl 2) or (i4 and $c)) xor key1);
Inc(optr);
//生成第二个明文字符
pOut[optr]:=chr((i2 and 3) or (((i2 and $3c) shl 2) or ((i4 and $3)) shl 2) xor key1);
Inc(optr);
//生成第三个明文字符
pOut[optr]:=chr((i3 and $3f) or ((i4 and $30) shl 2) xor key1);
Inc(optr);
end;
case (Size mod 4) of
//当密文有2个零头字符的处理
2:begin
//分别取出零头的2个字符
i1:=byte(pIn[iptr])-key2;
Inc(iptr);
i2:=byte(pIn[iptr])-key2;
Inc(iptr);
//生成零头明文字符
pOut[optr]:=chr((i1 and 3) or ((i1 and $3c) shl 2) or ((i2 and 3) shl 2) xor key1);
Inc(optr);
end;
//当密文有3个零头字符的处理
3:begin
//分别取出零头的3个字符
i1:=byte(pIn[iptr])-key2;
Inc(iptr);
i2:=byte(pIn[iptr])-key2;
Inc(iptr);
i3:=byte(pIn[iptr])-key2;
Inc(iptr);
//生成两个零头明文字符
pOut[optr]:=chr((i1 and 3) or ((i1 and $3c) shl 2) or (i3 and $0C) xor key1);
inc(optr);
pOut[optr]:=chr((i2 and 3) or ((i2 and $3c) shl 2) or ((i3 and $03) shl 2) xor key1);
Inc(optr);
end;
end;//case结束 ;
pOut[optr]:=#0;
DecodeA:=optr;
end;
var
i1,i2,i3,i4:byte;
i,iptr,optr:integer;
key1,key2:byte;
begin
key1:=$ac;
key2:=$3c;
iptr:=0;
optr:=0;
for i:=0 to (Size div 4)-1 do
begin
//依次取出4个字符
i1:=byte(pIn[iptr])-key2;
Inc(iptr);
i2:=byte(pIn[iptr])-key2;
Inc(iptr);
i3:=byte(pIn[iptr])-key2;
Inc(iptr);
i4:=byte(pIn[iptr])-key2;
Inc(iptr);
//生成第一个明文字符
pOut[optr]:=chr((i1 and 3) or (((i1 and $3c) shl 2) or (i4 and $c)) xor key1);
Inc(optr);
//生成第二个明文字符
pOut[optr]:=chr((i2 and 3) or (((i2 and $3c) shl 2) or ((i4 and $3)) shl 2) xor key1);
Inc(optr);
//生成第三个明文字符
pOut[optr]:=chr((i3 and $3f) or ((i4 and $30) shl 2) xor key1);
Inc(optr);
end;
case (Size mod 4) of
//当密文有2个零头字符的处理
2:begin
//分别取出零头的2个字符
i1:=byte(pIn[iptr])-key2;
Inc(iptr);
i2:=byte(pIn[iptr])-key2;
Inc(iptr);
//生成零头明文字符
pOut[optr]:=chr((i1 and 3) or ((i1 and $3c) shl 2) or ((i2 and 3) shl 2) xor key1);
Inc(optr);
end;
//当密文有3个零头字符的处理
3:begin
//分别取出零头的3个字符
i1:=byte(pIn[iptr])-key2;
Inc(iptr);
i2:=byte(pIn[iptr])-key2;
Inc(iptr);
i3:=byte(pIn[iptr])-key2;
Inc(iptr);
//生成两个零头明文字符
pOut[optr]:=chr((i1 and 3) or ((i1 and $3c) shl 2) or (i3 and $0C) xor key1);
inc(optr);
pOut[optr]:=chr((i2 and 3) or ((i2 and $3c) shl 2) or ((i3 and $03) shl 2) xor key1);
Inc(optr);
end;
end;//case结束 ;
pOut[optr]:=#0;
DecodeA:=optr;
end;