⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 untendescryptmain.~pas

📁 加密和解密的算法
💻 ~PAS
字号:
unit UntEnDeScryptMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons;

type
  TFrmEnDeScryptMain = class(TForm)
    BtnGetHardDiskID: TBitBtn;
    EdtHardDiskID: TEdit;
    BtnDescrypt: TBitBtn;
    EdtDescrypt: TEdit;
    procedure BtnGetHardDiskIDClick(Sender: TObject);
    procedure BtnDescryptClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmEnDeScryptMain:TFrmEnDeScryptMain;

implementation
uses UntDll;
{$R *.dfm}

//字符串加密函数的实现
function DataEncode(const s:string):string;
var
  i,c1,c2,c3:Integer;
  m,n:Integer;
const
   Data:string='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
begin
   Result:='';
   m:=1;
   n:=0;
   for i := 1 to (Length(s) div 3) do
   begin
      c1 := Ord(s[m]);
      c2 := Ord(s[m+1]);
      c3 := Ord(s[m+2]);
      m:=m+3;
      Result := Result+Data[(c1 shr 2)and $3F+1];
      Result := Result+Data[((c1 shl 4)and $30) or ((c2 shr 4)and $0F)+1];
      Result := Result+Data[((c2 shl 2)and $3C) or ((c3 shr 6)and $03)+1];
      Result := Result+Data[c3 and $3F+1];
      n:=n+4;
      if(n = 76)then
      begin
         n:=0;
         Result := Result+#13#10;
      end;
    end;
    if (Length(s) mod 3)=1 then
    begin
      c1 := Ord(s[m]);
      Result := Result+Data[(c1 shr 2)and $3F+1];
      Result := Result+Data[(c1 shl 4)and $30+1];
      Result := Result+'=';
      Result := Result+'=';
   end;
   if (Length(s) mod 3)=2 then
   begin
      c1 := Ord(s[m]);
      c2 := Ord(s[m+1]);
      Result := Result+ Data[(c1 shr 2)and $3F+1];
      Result := Result+ Data[((c1 shl 4)and $30) or ((c2 shr 4)and $0F)+1];
      Result := Result+Data[(c2 shl 2)and $3C+1];
      Result := Result+ '=';
   end;
end;

//字符串解密函数的实现
function DataDecode(const s:string):string;
var
 i,m,n:Integer;
 c1,c2,c3,c4:Integer;
const
   Data:string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
begin
   Result := '';
   n:=1;
   m:=Length(s);
   if s[m]='='then m:=m-1;
   if s[m]='='then m:=m-1;
   for i:=1 to m div 4 do
   begin
      c1:=Pos(s[n],Data)-1;
      c2:=Pos(s[n+1],Data)-1;
      c3:=Pos(s[n+2],Data)-1;
      c4:=Pos(s[n+3],Data)-1;
      n:=n+4;
      Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));
      Result:=Result+Chr(((c2 shl 4)and $F0)or((c3 shr 2)and $0F));
      Result:=Result+Chr(((c3 shl 6)and $C0)or c4);
   end;
   if m mod 4=2 then
   begin
      c1:=Pos(s[n],Data)-1;
      c2:=Pos(s[n+1],Data)-1;
      Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));
   end;
   if m mod 4=3 then
   begin
      c1:=Pos(s[n],Data)-1;
      c2:=Pos(s[n+1],Data)-1;
      c3:=Pos(s[n+2],Data)-1;
      Result:=Result+Chr(((c1 shl 2)and $FC)or((c2 shr 4)and $3));
      Result:=Result+Chr(((c2 shl 4)and $F0)or((c3 shr 2)and $0F));
   end;
end;



procedure TFrmEnDeScryptMain.BtnGetHardDiskIDClick(Sender: TObject);
begin
  //EdtHardDiskID.Text:=StrPas(GetHardDiskSeriID_Dll());
  //EdtHardDiskID.Text:=GetHardDiskSeriID_Dll();
  EdtHardDiskID.Text:=GetEnscryptHard();
end;

procedure TFrmEnDeScryptMain.BtnDescryptClick(Sender: TObject);
begin
  EdtDescrypt.Text:=GetDescryptHard(Trim(EdtHardDiskID.Text));
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -