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

📄 exspnamu.pas

📁 详细的ERP设计资料
💻 PAS
字号:
unit ExSpNamu;

interface

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

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    edtUserName1: TEdit;
    btnGenCode: TButton;
    edtCode1: TEdit;
    GroupBox2: TGroupBox;
    Label2: TLabel;
    edtUserName2: TEdit;
    edtCode2: TEdit;
    Label3: TLabel;
    btnCheckCode: TButton;
    lblCheckResult: TLabel;
    procedure btnGenCodeClick(Sender: TObject);
    procedure btnCheckCodeClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  OnGuard, OgUtil;

const
  Key : TKey = ($E8,$B5,$DF,$7F,$F7,$01,$C6,$4A,
                $24,$08,$02,$DC,$B0,$78,$CC,$43);


{ generate unlocking code based on user name }
procedure TForm1.btnGenCodeClick(Sender: TObject);
var
  HashValue : Longint;
  Code : TCode;
begin
  HashValue := StringHashElf(edtUserName1.Text);
  InitSpecialCode(Key, HashValue, Now + 30, Code);
  edtCode1.Text := BufferToHex(Code, SizeOf(Code));
end;

{ check unlocking code against a user name }
procedure TForm1.btnCheckCodeClick(Sender: TObject);
var
  HashValue : Longint;
  Code : TCode;
begin
  HexToBuffer(edtCode2.Text, Code, SizeOf(Code));
  if not IsSpecialCodeValid(Key, Code) then begin
    lblCheckResult.Caption := 'Code Invalid';
    Exit;
  end;
  if IsSpecialCodeExpired(Key, Code) then begin
    lblCheckResult.Caption := 'Code Expired';
    Exit;
  end;
  if GetSpecialCodeValue(Key, Code) <> StringHashElf(edtUserName2.Text) then
    lblCheckResult.Caption := 'User name doesn''t match'
  else
    lblCheckResult.Caption := 'OK';
end;

end.

⌨️ 快捷键说明

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