2 Star 8 Fork 3

闲散居士/数据库备份

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
U_des.pas 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
闲散居士 提交于 2021-12-08 10:58 . 清理源码注释
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.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Delphi
1
https://gitee.com/xyxia/oraback.git
git@gitee.com:xyxia/oraback.git
xyxia
oraback
数据库备份
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385