unit Generator;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit,
FMX.StdCtrls, FMX.Controls.Presentation, DateUtils;
type
TForm15 =
class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
edtUserName1: TEdit;
E_User: TEdit;
edtRegCode1: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
btnGenerate: TButton;
edtUserName2: TEdit;
E_User2: TEdit;
edtRegCode2: TEdit;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
btnVerify: TButton;
Label8: TLabel;
edtStatus: TEdit;
Label9: TLabel;
procedure btnGenerateClick(Sender: TObject);
procedure btnVerifyClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form15: TForm15;
implementation
{$R *.fmx}
uses FMX.onGuard, FMX.ogUtil;
const
EncryptionKey : TKey = ($E7, $88, $99, $D2, $82, $39, $AA, $FF,
$A7, $FA, $6F, $7F, $A9, $
CC, $
DC, $44);
procedure TForm15.btnGenerateClick(Sender: TObject);
var
Key : TKey;
Code : TCode;
Modifier : Longint;
Value: longint;
begin
Key := EncryptionKey;
Value := StrToInt(E_User.text);
Modifier := StringHashELF(edtUserName1.Text);
ApplyModifierToKeyPrim(Modifier, Key, SizeOf(Key));
InitSpecialCode(Key, Value, StrToDateTime('
01.01.1900'), Code);
edtRegCode1.Text := BufferToHex(Code, SizeOf(Code));
end;
procedure TForm15.btnVerifyClick(Sender: TObject);
var
Key : TKey;
Code : TCode;
Modifier : Longint;
Value: longint;
EXP_Date : TDateTime;
begin
Key := EncryptionKey;
Modifier := StringHashELF(edtUserName2.Text);
ApplyModifierToKeyPrim(Modifier, Key, SizeOf(Key));
HexToBuffer(edtRegCode2.Text, Code, SizeOf(Code));
Value := GetSpecialCodeValue (Key, Code);
exp_Date := GetExpirationDate (Key, Code);
E_User2.Text := IntToStr(Value);
if IsSpecialCodeValid(Key, Code)
then begin
if IsSpecialCodeExpired(Key, Code)
then
edtStatus.Text := '
Expired'
else
edtStatus.Text := '
Valid';
end else
edtStatus.Text := '
Not Valid';
end;
end.