Generate secure license keys
Random identifiers, issuance, validation and customer-friendly error handling
A secure license key is an unpredictable identifier backed by an entitlement your application can validate. A key's appearance does not enforce access: your server or a properly verified signed license must decide whether it may be used.
Generate unpredictable identifiers
Use a cryptographically secure random generator. Do not derive keys from customer email addresses, order numbers or timestamps. Prefixes and separators can improve readability, but fixed characters add no randomness.
This Python example generates a 128-bit random token for a system you operate. It does not create a PWF Auth license; use the panel or Developer API for that.
import secrets
token = secrets.token_hex(16).upper()
license_key = "-".join(token[i:i + 8] for i in range(0, len(token), 8))
print(license_key)A longer random key reduces accidental collisions and guessing risk, but it is only one part of the design. Enforce uniqueness when storing generated keys, rate-limit validation, and avoid putting full keys into analytics, public URLs or support screenshots.
Create working keys in PWF Auth
- Create an application and open Licenses.
- Choose Generate, a duration and the permitted number of machines.
- Use the standard format or configure your own format in Applications.
- Deliver the key to its customer through your store or another private delivery channel.
- Validate it with the SDK and start the heartbeat.
For your own checkout, issue keys through the Developer API from a trusted backend. Limit the API key to the required operations. A browser-facing key generator must never contain management credentials.
Separate the key from its policy
Store duration, permitted devices, status and customer entitlement as explicit records. Encoding a visible expiry date in a key does not make the entitlement trustworthy. On each relevant operation, use the validated state returned by the licensing service.
In PWF Auth, an unused key starts its duration on first sign-in. A machine binding controls which PCs can use it. A ban or pause changes whether the service accepts the next check-in. Those behaviors live in the licensing system, not in the printed key format.
Make failures understandable
- Invalid key: ask the customer to check what they entered.
- Expired key: explain how to renew.
- Device limit: offer your approved hardware reset flow.
- Connection failure: distinguish temporary connectivity from an explicit license refusal.
- Ended session: stop protected work and show the SDK's supported customer message.
Branch on documented error codes rather than matching message text. Test these outcomes with your own test keys before publishing a build.
Common questions
Does a random key alone protect an application?
No. The app must validate the entitlement and enforce the result. Client software can be inspected and modified, so no key format makes a desktop binary impossible to alter.
Can I import keys from another service?
Yes, key strings can be imported. The chosen duration starts fresh on the next sign-in, so importing strings does not automatically preserve the old expiry or device state. Read the migration checklist before moving paying customers.
Continue with the licensing API overview or custom key formats, then create your first application.
Something missing or unclear? Tell us on Telegram