Skip to main content

pylicensify

License key validation for Python that a cracked build can't fake.

Verify software license keys at runtime with Ed25519-signed responses, bind them to devices (HWID), sell concurrent seats, and activate offline — in a few lines.

PyPI Python License

pip install pylicensify
from pylicensify import LicenseClient

client = LicenseClient(public_key="YOUR_PUBLIC_KEY")

if not client.validate("PY-XXXXXXXXXXXXXXXX"):
    raise SystemExit("Not licensed")

# your app starts here

Why not just ask your own server?

Because the usual approach breaks in about five minutes.

Most licensing code sends the key somewhere and trusts whatever comes back. So an attacker doesn't attack your key format or your crypto — they point your app at a server of their own that answers {"valid": true} to everything. One line in /etc/hosts, and every copy is licensed forever.

The check was never the hard part. Making the answer impossible to forge is.

Every response from the license server is signed with an Ed25519 private key that never leaves the server. Your app embeds only the public key and verifies the signature locally:

your app  ──── key + random nonce ───▶  license server
          ◀─── result + signature ────  (signed with the private key)
              │
              └─ verified against the public key baked into your build
                 wrong signature → SignatureError, not "licensed"

A fake server can return a valid-looking JSON body, but it cannot produce a signature that verifies. Redirect the app anywhere you like — it fails closed.

The nonce and timestamp are signed too, so a genuine "yes" captured off the wire can't be replayed back later.


Quick start

Get your public key from the dashboard → Integration. It's safe to embed in a distributed app; the private key never leaves the server.

from pylicensify import LicenseClient

client = LicenseClient(public_key="YOUR_PUBLIC_KEY")

result = client.validate("PY-XXXXXXXXXXXXXXXX")

if not result:
    print("Not licensed:", result.error)
    raise SystemExit(1)

print("Licensed")

validate() generates a nonce, verifies the Ed25519 signature, and rejects stale or replayed responses automatically. It returns a falsy ValidationResult when the key is refused, and raises SignatureError on tampering or NetworkError when the server is unreachable.

Prefer exceptions to truthiness checks? Pass raise_on_invalid=True and a refused key raises InvalidLicense instead of returning a falsy result.


What you get

Signed validation Ed25519 on every response — forging a "yes" is not possible
Device binding Lock a key to n machines by hardware id
Entitlements One key unlocks different tiers — signed, so they can't be flipped
Floating licenses Sell n concurrent seats instead of n installs
Offline activation Signed .lic files that verify with no network at all
Update checks Ship new builds only to customers with a live license

Entitlements (feature gating)

Attach flags to a key — {"pro": true, "seats": 5} — and they arrive inside the signed payload, so a patched client can't turn them on:

result = client.validate(key)

if result.feature("pro"):
    enable_pro_features()

seats = result.feature("seats", 1)   # second arg is the default

A key with no entitlements returns an empty result.features dict — set them per key when you generate it.


Device binding (HWID)

Each key can be limited to a number of machines. The SDK sends a stable per-installation device id automatically:

from pylicensify import get_hwid

client.validate(key)                       # uses get_hwid() for you
client.validate(key, hwid=my_own_id())     # or supply your own

The default id is the machine's MAC address where one is readable, otherwise a random id persisted to disk and reused on every run. That matters more than it sounds: a naive uuid.getnode() changes between runs on Android/Pydroid, VMs and containers, which would burn through a customer's device limit on a single machine.

The persisted id lives in a per-user data dir — %LOCALAPPDATA%\pylicensify on Windows, ~/.local/share/pylicensify elsewhere. Override the location with the PYLICENSIFY_HWID_DIR environment variable.


Floating (concurrent) licenses

For teams: cap how many copies run at the same time rather than how many are installed. The SDK checks out a seat, heartbeats in the background, and releases it on exit — including when the process dies, because the lease simply expires.

from pylicensify import LicenseClient, SeatUnavailable

client = LicenseClient(public_key="YOUR_PUBLIC_KEY")

try:
    with client.session("PY-XXXXXXXXXXXXXXXX") as sess:
        print("Seat acquired:", sess.seats)   # {'used': 1, 'max': 5}
        run_app()                             # released automatically on exit
except SeatUnavailable:
    print("All seats are in use — try again later.")

The lower-level lease(), heartbeat() and release() methods are available if you need to drive the lifecycle yourself.


Offline activation (air-gapped)

Issue a signed .lic file, ship it with the app, and verify it locally with zero network calls — for air-gapped machines, regulated environments, or customers whose boxes are deliberately kept off the internet:

from pylicensify import verify_offline_license

data = verify_offline_license("YOUR_PUBLIC_KEY", "license.lic")
print("Valid for:", data.get("customer"), data.get("features"))

Verifies the signature, expiry, device binding and OS lock. It raises InvalidLicense if the file has expired or is bound to another machine, and SignatureError if it has been edited.

Offline files trade revocation for availability — the client never calls home, so you can't revoke one before it expires. Keep their lifetimes short.


Update checks

Serve new builds only to customers with a live license:

info = client.check_update("PY-XXXXXXXXXXXXXXXX", current_version="1.0.0")

if info["update_available"]:
    print("New version:", info["version"], info["notes"])
    # info["download_url"] only works while the key is active and unexpired

Errors

Exception Meaning
InvalidLicense Server refused the key — invalid, expired, revoked or blocked
SignatureError Signature, nonce or timestamp failed — forged or replayed
NetworkError Couldn't reach the license server
SeatUnavailable Floating license has no free seats

All inherit from LicenseError, so except LicenseError: catches everything.


Requirements

Python 3.8+, plus requests and cryptography (installed automatically).

You'll need an account for the server side — licers.com is free: unlimited keys, devices, validations, offline files and floating licenses, no card required.


Self-hosting and custom domains

By default the SDK calls the managed API at https://license.pyobfuscate.com. That host is deliberately permanent — shipped apps depend on it — while your dashboard and account live at licers.com. Point the client somewhere else for a self-hosted deployment:

client = LicenseClient(public_key="...", api_url="https://license.yourdomain.com")

Other options: timeout (seconds, default 5) and max_skew (how old a signed response may be before it's rejected as a replay, default 300s).


Hardening

Signed validation stops a forged answer. It doesn't stop someone deleting the question — patching the if not client.validate(...) line out of your bytecode. Obfuscate the client so that's meaningfully harder, for example with PyObfuscate.

Layered, that's: signature verification (can't fake a yes) + device binding (can't share one key everywhere) + obfuscation (can't trivially remove the check).


MIT licensed.

Metadata

Release files for pylicensify 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylicensify 1.0.3
File Size Uploaded Provenance Actions
pylicensify-1.0.3.tar.gz 14.9 kB Without provenance Details for pylicensify-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pylicensify 1.0.3
File Interpreter ABI Platform Actions
pylicensify-1.0.3-py3-none-any.whl Python 3 none any Details for pylicensify-1.0.3-py3-none-any.whl

Total release size: 26.7 kB

Release files / pylicensify-1.0.3.tar.gz

Download URL pylicensify-1.0.3.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ae1e7502459d4ea55ebc2db32ca027f35065228871e41b20c0625d790959393a
BLAKE2b-256 checksum
How to use checksums
eed09e2588ffa17a8f90ffdb617500a241729f686209a79856332def7bfea418
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / pylicensify-1.0.3-py3-none-any.whl

Download URL pylicensify-1.0.3-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20818be75a677faac72965dcfc671d20b1c5f18583f2c26fd39992b5b4d445c8
BLAKE2b-256 checksum
How to use checksums
7ee906c32af197645b0608761adef456e9fdaac1fee5373d77fd6a8e6e28894c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for pylicensify 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page