寻求一加密、解密算法:***在线*** 寻求一加密、解密算法:四位整数加密成另四位整数,并能还原!!谢谢思路,代码均可!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Function EncryptionEngine(Src:String; Key:String; Encrypt : Boolean):string;var idx :integer; KeyLen :Integer; KeyPos :Integer; offset :Integer; dest :string; SrcPos :Integer; SrcAsc :Integer; TmpSrcAsc :Integer; Range :Integer;begin KeyLen:=Length(Key); if KeyLen = 0 then key:='XHFJY'; KeyPos:=0; SrcPos:=0; SrcAsc:=0; Range:=256; if Encrypt then begin 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; end else begin offset:=StrToInt('$'+ copy(src,1,2)); SrcPos:=3; repeat SrcAsc:=StrToInt('$'+ copy(src,SrcPos,2)); if KeyPos < KeyLen Then KeyPos := KeyPos + 1 else KeyPos := 1; TmpSrcAsc := SrcAsc xor Ord(Key[KeyPos]); if TmpSrcAsc <= offset then TmpSrcAsc := 255 + TmpSrcAsc - offset else TmpSrcAsc := TmpSrcAsc - offset; dest := dest + chr(TmpSrcAsc); offset:=srcAsc; SrcPos:=SrcPos + 2; until SrcPos >= Length(Src); end; Result:=Dest;end; 不好意思!我现在有一个这样的情况:我调用了一家公司的动态库,有个后遗症:那就是不能用length函数!:( http://www.csdn.net/cnshare/soft/13/13920.shtm 关于shockwaveflash控件的简单问题 计算器问题请教 請問怎麼判斷今天是5.1,5.2,5.3或10.1,10.2,10.3。 用DELPHI做录音机 关于正玄函数的小问题(很简单的)在线等 QuickReport输出问题 如何清内存 come on !help me! 请教出现问题:“Query1:No SQL Statement available.” 关于treeview的问题,第一次发贴,希望大家多给予解答,谢谢。 见鬼的问题(dbgrid) 请问哪里有加密解密算法原理和实现的书籍或者网站?
var
idx :integer;
KeyLen :Integer;
KeyPos :Integer;
offset :Integer;
dest :string;
SrcPos :Integer;
SrcAsc :Integer;
TmpSrcAsc :Integer;
Range :Integer;begin
KeyLen:=Length(Key);
if KeyLen = 0 then key:='XHFJY';
KeyPos:=0;
SrcPos:=0;
SrcAsc:=0;
Range:=256;
if Encrypt then
begin
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;
end
else
begin
offset:=StrToInt('$'+ copy(src,1,2));
SrcPos:=3;
repeat
SrcAsc:=StrToInt('$'+ copy(src,SrcPos,2));
if KeyPos < KeyLen Then KeyPos := KeyPos + 1 else KeyPos := 1;
TmpSrcAsc := SrcAsc xor Ord(Key[KeyPos]);
if TmpSrcAsc <= offset then
TmpSrcAsc := 255 + TmpSrcAsc - offset
else
TmpSrcAsc := TmpSrcAsc - offset;
dest := dest + chr(TmpSrcAsc);
offset:=srcAsc;
SrcPos:=SrcPos + 2;
until SrcPos >= Length(Src);
end;
Result:=Dest;
end;
我现在有一个这样的情况:
我调用了一家公司的动态库,有个后遗症:
那就是不能用length函数!:(