代码拉取完成,页面将自动刷新
unit U_des;
interface
uses SysUtils,Cryptcon,Desunit2,rjmime;
function ArrayLength(a:Array of char):integer;
function encode_string(s:string):string;
function decode_string(s:string ):string;
implementation
var
boutarray: array[0..31] of char; //
function ArrayLength(a:Array of char):integer;
var i:integer;
begin
Result:=0;
for i:=high(boutarray)-1 downto 0 do begin
if (boutarray[i]<>#0) and (i<>0) then begin
Result:=i+1;
Break;
end;
end;
end;
function encode_string(s:string):string;
var j:integer;
des1:Tdes;
begin
if length(trim(s))=0 then begin
result:='';
exit;
end;
des1 := Tdes.Create(nil);
try
fillchar(boutarray,sizeof(boutarray),#0);
des1.Key := 'abcdefghijklmnopqrstuvwxyz';
DES1.InputLength:=length(s);
des1.InputString := s;
des1.InputType := SourceString;
des1.pOutputArray := @boutarray;
des1.EncipherData(False);
j:=ArrayLength(boutarray);
SetString(s,boutarray,j);
result:=MimeEncodeString(s)
finally
des1.Destroy;
end;
end;
function decode_string(s:string ):string;
var s1:string;ot:array[0..31] of char;
i:integer;
des1:Tdes;
begin
if length(trim(s))=0 then begin
result:='';
exit;
end;
des1 := Tdes.Create(nil);
try
fillchar(boutarray,sizeof(boutarray),#0);
fillchar(ot,sizeof(ot),' ');
s1:=MimeDecodeString(s);
for i:=1 to length(s1) do begin
boutarray[i-1]:=s1[i];
end;
des1.Key := 'abcdefghijklmnopqrstuvwxyz';
des1.InputLength := length(s1);//8;
des1.CipherMode := ECBMode;
des1.pInputArray := @boutarray;
des1.InputType := SourceByteArray;
des1.pOutputArray :=@ot;
des1.DecipherData(False);
i:=ArrayLength(ot);
SetString(s1, ot, i);
Result:=trim(s1);
finally
des1.Destroy;
end;
end;
end.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。