2008-10-31 21:18:20 +00:00
|
|
|
unit ExReg1;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2023-02-20 17:36:51 +00:00
|
|
|
SysUtils, Classes,Controls, Forms, Dialogs, StdCtrls, ComCtrls, Buttons;
|
2008-10-31 21:18:20 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TfrmExRegCode }
|
|
|
|
|
|
|
|
TfrmExRegCode = class(TForm)
|
|
|
|
edDate: TEdit;
|
|
|
|
GroupBox1: TGroupBox;
|
|
|
|
Label1: TLabel;
|
|
|
|
edtUserName1: TEdit;
|
|
|
|
Label2: TLabel;
|
|
|
|
Label3: TLabel;
|
|
|
|
edtRegCode1: TEdit;
|
|
|
|
GroupBox2: TGroupBox;
|
|
|
|
edtUserName2: TEdit;
|
|
|
|
Label4: TLabel;
|
|
|
|
edtRegCode2: TEdit;
|
|
|
|
Label5: TLabel;
|
|
|
|
Label6: TLabel;
|
|
|
|
edtStatus: TEdit;
|
|
|
|
btnGenerate: TSpeedButton;
|
|
|
|
btnVerify: TSpeedButton;
|
|
|
|
procedure btnGenerateClick(Sender: TObject);
|
|
|
|
procedure btnVerifyClick(Sender: TObject);
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
private
|
|
|
|
{ Private declarations }
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
frmExRegCode: TfrmExRegCode;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2023-02-20 17:36:51 +00:00
|
|
|
{$R *.lfm}
|
2008-10-31 21:18:20 +00:00
|
|
|
|
|
|
|
uses
|
|
|
|
OnGuard, OgUtil;
|
|
|
|
|
|
|
|
const
|
|
|
|
EncryptionKey : TKey = ($E5, $8F, $84, $D6, $92, $C9, $A4, $D8,
|
|
|
|
$1A, $FA, $6F, $8D, $AB, $FC, $DF, $B4);
|
|
|
|
|
|
|
|
procedure TfrmExRegCode.btnGenerateClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
Key : TKey;
|
|
|
|
Code : TCode;
|
|
|
|
Modifier : Longint;
|
|
|
|
D : TDateTime;
|
2023-02-17 16:28:47 +00:00
|
|
|
var
|
|
|
|
fs: TFormatSettings;
|
2008-10-31 21:18:20 +00:00
|
|
|
begin
|
2023-02-20 17:36:51 +00:00
|
|
|
if not TryStrToDate(edDate.Text, D) then
|
|
|
|
begin
|
|
|
|
fs := FormatSettings;
|
|
|
|
fs.ShortDateFormat := 'yyyy/mm/dd';
|
|
|
|
fs.DateSeparator := '-';
|
|
|
|
if not TryStrToDate(edDate.Text, D, fs) then
|
|
|
|
begin
|
|
|
|
MessageDlg('Invalid date.', mtError, [mbOK], 0);
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
2008-10-31 21:18:20 +00:00
|
|
|
Key := EncryptionKey;
|
|
|
|
Modifier := StringHashELF(edtUserName1.Text);
|
|
|
|
ApplyModifierToKeyPrim(Modifier, Key, SizeOf(Key));
|
2023-02-23 13:55:39 +00:00
|
|
|
InitRegCode(Key, '', D, Code{%H-});
|
2008-10-31 21:18:20 +00:00
|
|
|
edtRegCode1.Text := BufferToHex(Code, SizeOf(Code));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmExRegCode.btnVerifyClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
Key : TKey;
|
|
|
|
Code : TCode;
|
|
|
|
Modifier : Longint;
|
|
|
|
begin
|
|
|
|
Key := EncryptionKey;
|
|
|
|
Modifier := StringHashELF(edtUserName2.Text);
|
|
|
|
ApplyModifierToKeyPrim(Modifier, Key, SizeOf(Key));
|
2023-02-20 17:36:51 +00:00
|
|
|
Code := Default(TCode);
|
2008-10-31 21:18:20 +00:00
|
|
|
HexToBuffer(edtRegCode2.Text, Code, SizeOf(Code));
|
|
|
|
if IsRegCodeValid(Key, Code) then begin
|
|
|
|
if IsRegCodeExpired(Key, Code) then
|
|
|
|
edtStatus.Text := 'Expired'
|
|
|
|
else
|
|
|
|
edtStatus.Text := 'Valid';
|
|
|
|
end else
|
|
|
|
edtStatus.Text := 'Not Valid';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfrmExRegCode.FormCreate(Sender: TObject);
|
2023-02-17 16:28:47 +00:00
|
|
|
var
|
|
|
|
fs: TFormatSettings;
|
2008-10-31 21:18:20 +00:00
|
|
|
begin
|
2023-02-17 16:28:47 +00:00
|
|
|
fs := FormatSettings;
|
|
|
|
fs.ShortDateFormat := 'yyyy/mm/dd';
|
|
|
|
fs.DateSeparator := '-';
|
|
|
|
edDate.Text := DateToStr(Now, fs);
|
2008-10-31 21:18:20 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|