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

📄 unit2.pas

📁 提供字符串、文件 及 Memory Streams 加密/解密的控件 ( 2.1 版
💻 PAS
字号:
unit Unit2;

{ a part of this unit was written by S. Maksutin. Thanks. }

interface

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

type
  TForm2 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Memo1: TMemo;
    Start: TButton;
    BCancel: TButton;
    Label3: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    procedure FormShow(Sender: TObject);
    procedure BCancelClick(Sender: TObject);
    procedure StartClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form2: TForm2;
  Chars    : shortstring;
  i, j, k, MaxCount, PassLength : integer;
  pass : shortstring;
  arrows : array[1..12] of byte;
  CloseFlag : boolean;
  exitf    : boolean ;

implementation

{$R *.DFM}

procedure TForm2.FormShow(Sender: TObject);
begin
  Label1.Caption:='Your password is:   '+Form1.CryptLib1.Password+'   let`s try to crack it using hash';
  Edit1.Text:=Form1.EditHash.Text;
  PassLength:=12;  //  Maximum password length
end;

procedure TForm2.BCancelClick(Sender: TObject);
begin
  CloseFlag:=true;
end;

procedure TForm2.StartClick(Sender: TObject);

  procedure Inc_Position(num : byte)  ;
  begin
   exitf:=false;
   if (arrows[num] < Maxcount)
    then
     begin
       inc(arrows[num]) ;
       pass[PassLength+1-num] := chars[arrows[num]] ;
     end
    else
      begin
        arrows[num] := 1 ;
        pass[PassLength+1-num] := chars[1] ;
        if (num = PassLength)
        then
          begin
            exitf := TRUE ;
            exit;
          end
        else Inc_Position(num+1) ;
      end ;
  end ;

var   i, j : integer;
      starttime : TTime;
begin
  CloseFlag:=false;
  starttime:=time();
  k:=1;
  for i:=0 to Memo1.Lines.Count-1 do
    for j:=1 to length(Memo1.Lines[i]) do
      begin
        Chars[k]:=Memo1.Lines[i][j];
        inc(k);
      end;
  MaxCount:=k-1;
  pass[0] := Chr(PassLength) ;
  for i := 1 to PassLength do
  begin
    arrows[i] := 0 ;
    pass[i] := #$20 ;
  end ;
  i:=0;
  Inc_Position(1) ;
  repeat
     if Form1.CryptLib1.PasswdIsGood(Edit1.Text,trim(pass))=true then
     begin
       ShowMessage('Your password is:   '+pass+'     time:   '+TimeToStr(time()-starttime));
       Label3.Caption:=pass;
       exit;
     end;
     if i=1000
     then
       begin
         Label3.Caption:=pass;
         Application.ProcessMessages;
         if CloseFlag then exit;
         i:=0;
       end
     else inc(i);
     Inc_Position(1) ;
  until (exitf) ;
  Label3.Caption:='';
  ShowMessage('Password not found. Sorry :((');
end;

end.

⌨️ 快捷键说明

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