Implementing License Key Generation and Validation on Your Site
Software without license protection is a magnet for pirates. Each illegal launch means a lost license, reputational damage, and support risks. We develop and integrate a license key generation and validation system that solves these problems: unique keys resistant to forgery, with both online and offline verification. Integration takes 4–6 business days, and the result is reliable protection with automated activation. Contact us — we'll evaluate your project and propose the best solution.
What Problems Does the System Solve?
Software developers face several typical challenges. The first is creating keys that cannot be guessed or generated using standard utilities. Simple random keys are easily brute-forced when no API is involved; PKV keys provide partial protection but can be modified without a server call. The second problem is activation count control: without server logic, a single key can be installed on dozens of machines. The third is the need for offline validation for users without permanent internet access. Our system addresses all these points: we use cryptographically signed JWT tokens with RSA-2048 that can be verified locally, plus a server API for activation management.
How Does a JWT License Work?
A JWT license is a token containing a payload (product ID, plan, validity period, max seats) signed with a private key. The client verifies the signature using the public key — no internet connection is required. This reduces server load and allows offline operation. For example, in a PHP backend, generation looks like this:
use Firebase\JWT\JWT;
class LicenseTokenService
{
public function issue(License $license): string
{
$privateKey = file_get_contents(storage_path('keys/license_private.pem'));
return JWT::encode([
'iss' => 'example.com',
'iat' => now()->timestamp,
'exp' => $license->expires_at?->timestamp ?? 9999999999,
'license_id' => $license->id,
'product' => $license->product_code,
'plan' => $license->plan,
'seats' => $license->max_seats,
'features' => $license->features,
], $privateKey, 'RS256');
}
public function verify(string $token): array
{
$publicKey = file_get_contents(storage_path('keys/license_public.pem'));
$payload = JWT::decode($token, new Key($publicKey, 'RS256'));
return (array) $payload;
}
}
Why Is Offline Validation Important?
Users may work in remote locations, on planes, or on secured networks without access to your API. If validation requires constant online contact, the program would be blocked. JWT with asymmetric signatures solves this: the client stores the public key and verifies the token locally. The only downside is that the expiration date in the token is checked against the device's clock, which the user could roll back. Therefore, for critical licenses, we recommend combining offline verification with periodic server synchronization.
Key Format Comparison
| Format | Security | Offline Validation | Size | Implementation Complexity |
|---|---|---|---|---|
| Random key | Low (uniqueness only) | No | 25 chars | Minimal |
| Partial Key Verification | Medium (encodes attributes) | Partial | 25–40 chars | Medium |
| JWT (RSA signed) | High (cryptographic signature) | Full | ~500–800 base64 | Higher (requires keys) |
Online Validation API
A server endpoint checks the key in real time: status, expiration, activation count. Example in Laravel:
Route::post('/api/v1/licenses/validate', function (Request $request) {
$key = $request->input('key');
$license = License::where('key', $key)->first();
if (!$license) {
return response()->json(['valid' => false, 'error' => 'Invalid key'], 404);
}
$checks = [
'active' => $license->status === 'active',
'not_expired'=> !$license->expires_at || now()->isBefore($license->expires_at),
'seats_ok' => $license->activations()->where('revoked', false)->count() < $license->max_activations,
];
$valid = !in_array(false, $checks);
return response()->json([
'valid' => $valid,
'product' => $license->product_code,
'plan' => $license->plan,
'expires_at' => $license->expires_at,
'errors' => array_keys(array_filter($checks, fn($v) => !$v)),
]);
});
What Is Included in the Work
When you order integration, you get:
- Selection of key scheme and format tailored to your requirements;
- Backend generation implementation (Laravel/Node.js/Python);
- Client validation library (C#, Java, Swift, or JS);
- API for activation, deactivation, and status checks;
- Admin panel for license management (create, revoke, view statistics);
- Integration documentation and team training;
- Support for 30 days after delivery.
Process of Work
- Analysis: We review your distribution model, define required plans, restrictions, and user counts.
- Design: We choose the key format, design the signing scheme, API, and activation policies.
- Implementation: We write code in your stack (or embed into Laravel/Node.js/Python if not specified).
- Testing: We verify scenarios — correct activation, revocation, limit exceeded, key forgery.
- Deployment: We deploy on your server, hand over access and documentation.
Timeline Estimates
A standard setup (JWT + API) takes 4–6 business days. Complex integrations (multiple platforms, migrating existing keys) may take up to 10 days. Pricing is individual — contact us to discuss.
Common Implementation Mistakes
- Caching the public key with expiration — leads to lock after rotation.
- Ignoring the revoke list — old keys continue to work.
- Weak signing algorithm (HS instead of RS) — key can be recovered if the hash is leaked.
- No rate limit on the validation API — vulnerable to brute force.
With over 7 years of experience in software protection and licensing system integration — more than 50 projects including desktop, mobile, and web applications — we deliver reliable protection without hassle. Order integration and get peace of mind.







