?? exspnamu.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 + -