Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

DFLicencer2.0

HMAC-SHA256 signed software licensing for Delphi 10.3 Rio and later (VCL / Windows).

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

DFLicencer 2.0

HMAC-SHA256 signed software licensing for Delphi 10.3 Rio and later (VCL / Windows).

Website: delphifan.com
Email: adsdelphi@gmail.com
License: MIT

English · Türkçe


English

Why 2.0?

Version 1.x used fake encryption (EncodeString) and ContainsStr checks, which were easy to spoof and brittle with dates. 2.0 signs a JSON payload with HMAC-SHA256, and adds optional hardware binding, feature flags, license types, and a drop-in TDFLicencer component.

Version 1.x keys are not compatible with 2.0.

Features

  • Signed license token: DFL2.<payload>.<signature>
  • Trial / Standard / Professional / Enterprise / Perpetual
  • Expiry date or never-expires
  • Grace period after expiry
  • Feature flags (reports, export, ...)
  • Optional hardware binding (machine ID)
  • Application version range (MinVersion / MaxVersion)
  • Storage in license.lic or .ini
  • Palette component: TDFLicencer (DF Licencer)
  • Runtime + design-time packages (Win32 design-time, Win32/Win64 runtime)

Package install

  1. Open packages\DFLicencer.groupproj in Delphi 10.3+.
  2. Build DFLicencer (runtime), then DFLicencerDesign.
  3. Install the design-time package: Component > Install Packages > Add and select bin\Win32\Release\DFLicencerDesign.bpl (output folder may differ).
  4. TDFLicencer appears on the Tool Palette under DF Licencer.

Alternatively, add the units from source\ to your project. The demos compile this way; installing the BPL is optional.

Quick start

Use the same ProductId and SecretKey in the generator and in your application. The secret is compiled into the binary — use your own long random value in production.

delphi
uses
  DFLicencer.Component, DFLicencer.Types;

procedure TFormMain.FormCreate(Sender: TObject);
begin
  DFLicencer1.ProductId := 'com.mycompany.myapp';
  DFLicencer1.SecretKey := 'your-long-random-secret';
  DFLicencer1.LicenseFile := 'license.lic';
  DFLicencer1.AppVersion := '2.0.0';
  DFLicencer1.HardwareBinding := False;
  DFLicencer1.GraceDays := 3;

  DFLicencer1.CheckLicense;
  if not DFLicencer1.IsLicensed then
  begin
    ShowMessage(DFLicencer1.StatusText);
    Application.Terminate;
    Exit;
  end;

  if DFLicencer1.HasFeature('export') then
    EnableExport;
end;

Generate a key (in your generator / sales tool):

delphi
uses
  DFLicencer.Core, DFLicencer.Types;

var
  Info: TDFLicenseInfo;
  Key: string;
begin
  Info.Clear;
  Info.ProductId := 'com.mycompany.myapp';
  Info.ProductName := 'My App';
  Info.CustomerName := 'Acme Ltd';
  Info.LicenseType := ltProfessional;
  Info.IssuedAt := Date;
  Info.ExpiresAt := EncodeDate(2027, 12, 31);
  Info.Features := 'reports;export;api';
  Info.Seats := 5;
  Key := TDFLicenseCodec.Generate(Info, 'your-long-random-secret');
end;

Activate in the customer app:

delphi
DFLicencer1.Activate(PastedKey);

If the key is valid, it is saved to LicenseFile.

TDFLicencer

Property Description
ProductId Product identity the license is bound to
SecretKey HMAC secret (must match the generator)
LicenseFile license.lic or .ini
AppVersion Used for min/max version checks
HardwareBinding When True, the license is locked to this machine
GraceDays Extra days after expiry
AutoCheck Validate in Loaded (skipped at design-time)
OnStatus Status callback

Methods: CheckLicense, Activate, HasFeature, DaysRemaining, MachineId, IsLicensed, StatusText.

Demos

  • demo\Generator — license generator
  • demo\SampleApp — paste a key and activate

Sample Product ID (both demos): com.delphifan.sample
Sample secret: change-this-secret-in-production

Requirements

  • RAD Studio / Delphi 10.3 Rio or later
  • Windows (machine ID is Win32/Win64)

Contributing

Issues and pull requests are welcome. Feedback: adsdelphi@gmail.com


Türkçe

HMAC-SHA256 imzalı lisans bileşeni. Delphi 10.3 Rio ve sonrası (VCL / Windows).

Neden 2.0?

  1. sözde şifreleme (EncodeString) ve ContainsStr ile doğrulama kullanıyordu; anahtar kırma ve tarih parse hatalarına açıktı. 2.0 lisans anahtarını JSON + HMAC-SHA256 ile imzalar, isteğe bağlı donanım bağlama, özellik bayrakları, lisans tipleri ve TDFLicencer bileşeni sunar.
  1. anahtarları 2.0 ile açılmaz.

Özellikler

  • DFL2.<payload>.<imza> formatında imzalı lisans tokeni
  • Deneme / Standard / Professional / Enterprise / Perpetual
  • Bitiş tarihi veya süresiz lisans
  • Grace period
  • Feature flag (reports, export, ...)
  • İsteğe bağlı hardware binding (makine kimliği)
  • Uygulama sürüm aralığı (MinVersion / MaxVersion)
  • license.lic veya .ini kaydı
  • Palet bileşeni: TDFLicencer (DF Licencer)
  • Runtime + design-time paket (Win32 design-time, Win32/Win64 runtime)

Kurulum (paket)

  1. packages\DFLicencer.groupproj dosyasını Delphi 10.3+ ile açın.
  2. Önce DFLicencer (runtime), sonra DFLicencerDesign projesini derleyin.
  3. Design-time paketi için: Component > Install Packages > Add ve bin\Win32\Release\DFLicencerDesign.bpl dosyasını seçin (çıktı klasörü ayarlara göre değişebilir).
  4. Tool Palette üzerinde DF Licencer kategorisinde TDFLicencer görünür.

Alternatif: kaynak unitlerini (source\) doğrudan projenize ekleyebilirsiniz. Demolar bu şekilde derlenir; paket kurulumu şart değildir.

Hızlı kullanım

Aynı ProductId ve SecretKey hem generator hem uygulamanızda olmalıdır. Secret key binary içinde durur; gerçek üründe kendi gizli değerinizi kullanın.

Kod örnekleri yukarıdaki Quick start bölümündedir.

Müşteri uygulamasında aktivasyon: DFLicencer1.Activate(PastedKey); — geçerliyse anahtar LicenseFile yoluna yazılır.

TDFLicencer

Özellik Açıklama
ProductId Lisansın bağlı olduğu ürün kimliği
SecretKey HMAC anahtarı (generator ile aynı)
LicenseFile license.lic veya .ini
AppVersion Sürüm kısıtı için
HardwareBinding True ise lisans makine kimliğine kilitlenir
GraceDays Süresi dolunca kısa ek süre
AutoCheck Loaded anında kontrol (design-time hariç)
OnStatus Sonuç bildirimi

CheckLicense, Activate, HasFeature, DaysRemaining, MachineId, IsLicensed, StatusText.

Demolar

  • demo\Generator — lisans üreteci
  • demo\SampleApp — anahtarı yapıştırıp aktive eden örnek uygulama

İkisinde de örnek Product ID: com.delphifan.sample
Örnek secret: change-this-secret-in-production

Gereksinimler

  • RAD Studio / Delphi 10.3 Rio veya daha yeni
  • Windows (makine kimliği Win32/Win64)

Katkı

Issue ve PR gönderilebilir. Geri bildirim: adsdelphi@gmail.com