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

📄 unit2.pas

📁 实现DEA加密和解密算法
💻 PAS
字号:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Panel2: TPanel;
    Label3: TLabel;
    Edit2: TEdit;
    Panel1: TPanel;
    Label1: TLabel;
    Button3: TButton;
    Panel3: TPanel;
    Button2: TButton;
    Button1: TButton;
    Label2: TLabel;
    SaveDialog1: TSaveDialog;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation
uses unit1;

{$R *.dfm}

type
TIntFunction=function(ip:pchar;i:pchar;o:pchar;b:integer;k:integer;kc:pchar):Integer;stdcall;
const
   DllName= 'aesdll.dll';


procedure TForm2.Button1Click(Sender: TObject);
 var
    FPointer1:TFarProc;
    HInst:THandle;
    dllencrypt:TIntFunction;
    ProcName1:PChar;
    inpath:array[0..50] of char;
    infile:array[0..50] of char;
    outfile:array[0..50] of char;
   // outpath:array[0..50] of char;
    KCX:array[0..50] of char;
    BC:integer;
    KC:integer;
    re:integer;

begin
     lstrcpy(inpath,pchar(Form1.Label4.Caption));
     lstrcpy(infile,pchar(Form1.edit2.Text));
     lstrcpy(outfile,pchar(edit1.Text));
     lstrcpy(KCX,pchar(edit2.Text));
    Case Form1.RadioGroup1.ItemIndex of
      0:BC:=4;
      1:BC:=6;
      2:BC:=8;
    end;
    Case Form1.RadioGroup2.ItemIndex of
      0:KC:=4;
      1:KC:=6;
      2:KC:=8;
    end;
    ProcName1:='dllencrypt';
    HInst:=SafeLoadLibrary(DllName);
    if HInst>0 then
       try
         FPointer1:=GetProcAddress(HInst,ProcName1);
         if FPointer1<>Nil then
            begin
              dllencrypt:=TIntFunction(FPointer1);
              re:=dllencrypt(inpath,infile,outfile,BC,KC,KCX);
              if re=0 then
                ShowMessage('加密失败!')
              else
                 ShowMessage('加密成功!')
            end
         else
           ShowMessage('找不到DLL函数!');
        finally
          FreeLibrary(HInst);
        end
     else
     ShowMessage(DllName + 'Library not found!');
     form2.Release;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
form2.Release;
end;

procedure TForm2.Button3Click(Sender: TObject);
begin
  with savedialog1 do
   if execute then
     edit1.Text:=filename;
end;

end.

⌨️ 快捷键说明

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