Offline mode with .dat

DevKanan lets your apps work without internet using RSA-signed .dat files. Two typical scenarios:

Scenario A: Online activation → offline usage afterward

The customer has internet the first time. Your app activates against the server, saves the signed .dat, then runs offline.

from devkanan import Key, LicenseKey, Helpers
from pathlib import Path

LICENSE_FILE = Path("license.dat")

# If .dat exists, validate offline (no internet needed)
if LICENSE_FILE.exists():
    lk = LicenseKey.load_from_string(
        RSA_PUB_KEY,
        LICENSE_FILE.read_text(encoding="utf-8-sig"),
        max_age_days=7,  # re-validate online every 7 days
    )
    if lk and lk.is_on_right_machine(Helpers.GetMachineCode(v=2)):
        start_app()
        exit()

# First run or .dat expired: activate online
result, msg = Key.activate(...)
LICENSE_FILE.write_text(json.dumps(response_full))
start_app()

Scenario B: 1 PC offline, no internet ever

Admin generates a .dat for the customer's machine code, delivers it physically. App never reaches the server.

In the panel

  1. Customer sends their machine code
  2. In the license: Register machine with that code
  3. Generate offline file .dat and download
  4. Deliver via email/USB

In the customer's app

from devkanan import LicenseKey, Helpers

with open("license.dat", encoding="utf-8-sig") as f:
    lk = LicenseKey.load_from_string(RSA_PUB_KEY, f.read(), max_age_days=0)

if not lk or not lk.is_on_right_machine(Helpers.GetMachineCode(v=2)):
    print("Invalid license")
    exit(1)

max_age_days=0 means "no freshness check" — the .dat is valid until its expiration date.

DevKanan Server (on-premise proxy)

For corporate customers with no internet in their network, install DevKananServer locally. It serves .dat files to client apps and handles floating seats. See self-hosted.