Skip to main content

devkanan

PyPI version Python License

Lightweight Python client to activate and validate RSA-signed licenses issued by the DevKanan platform or an on-premise DevKananServer.

Installation

pip install devkanan

Usage

Online activation

from devkanan import Key, Helpers

result, msg = Key.activate(
    token=ACCESS_TOKEN,
    rsa_pub_key=RSA_PUBLIC_KEY,
    product_id=100000,
    key="ABCD-EFGH-IJKL-MNOP",
    machine_code=Helpers.GetMachineCode(v=2),
    # floating_time_interval=300,  # optional floating lease
    server_url="https://devkanan.dev",  # optional
)

if result is None:
    print(f"Activation failed: {msg}")
    exit(1)

if result.is_on_right_machine(Helpers.GetMachineCode(v=2)) and result.has_not_expired():
    print("License valid — app can start")

Offline validation (signed .dat file)

from devkanan import LicenseKey, Helpers

RSA_PUB_KEY = """-----BEGIN PUBLIC KEY-----
... your tenant's RSA public key ...
-----END PUBLIC KEY-----"""

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

if lk is None:
    print("Invalid license (corrupt signature, expired or blocked)")
    exit(1)

if not lk.is_on_right_machine(Helpers.GetMachineCode(v=2)):
    print("This machine is not authorized")
    exit(1)

# Features
if lk.F1:
    enable_pro_features()

Usage credits

from devkanan import Credits

# Consume credits when a premium feature is used
ok, balance, msg = Credits.record(
    token=ACCESS_TOKEN, product_id=100000, key=LICENSE_KEY,
    amount=10, feature="export_pdf",
)

# Check current balance
enabled, balance, msg = Credits.balance(
    token=ACCESS_TOKEN, product_id=100000, key=LICENSE_KEY,
)

API

Helpers.GetMachineCode(v=2)

Generates a unique machine code based on hardware properties. v=2 (default) uses BIOS UUID via PowerShell on Windows or /etc/machine-id on Linux. Produces the same hash as the Cryptolens SDK.

LicenseKey.load_from_string(rsa_pub_key, content, max_age_days=0)

Parses a .dat, verifies the RSA signature and freshness.

Parameter Type Description
rsa_pub_key str XML (.NET) or PEM (standard). Auto-detected.
content str .dat file contents
max_age_days int Max days since signDate before re-validation is required. 0 = no limit.

Returns a LicenseKey object or None if any check fails.

LicenseKey methods

  • is_on_right_machine(machine_code) — verifies the machine is authorized
  • has_not_expired() — verifies expires > now
  • has_feature(n) — shortcut for getattr(lk, f'f{n}') (n = 1..8)

LicenseKey attributes

Attribute Type
product_id, id, key, notes basic data
created, expires, sign_date unix timestamps
period, max_no_of_machines integers
F1..F8, block, trial_activation flags
activated_machines List[ActivatedMachine]
data_objects List[DataObject]
customer Customer or None
offline_mode "FloatingLease" / "FloatingManual" / "Locked"

Comparison with Cryptolens SDK

Cryptolens SDK devkanan
Online activation ✅ ✅
Offline .dat / .skm validation ✅ ✅
Helpers.GetMachineCode ✅ ✅ (same hash)
LicenseKey.load_from_string ✅ ✅
Size ~2 MB with deps ~10 KB
Dependencies pycryptodome, requests cryptography, requests

Documentation

License

Apache 2.0. Partially based on Cryptolens Python SDK (also Apache 2.0).

Metadata

Release files for devkanan 0.2.2

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

Source distribution (sdist)

Source distribution for devkanan 0.2.2
File Size Uploaded Provenance Actions
devkanan-0.2.2.tar.gz 11.6 kB Without provenance Details for devkanan-0.2.2.tar.gz

Built distribution (wheel)

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

Total release size: 22.8 kB

Release files / devkanan-0.2.2.tar.gz

Download URL devkanan-0.2.2.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
27d5a81da66c130243ab18376f8c3b046a8d365f44513153cef1f625f65acdfc
BLAKE2b-256 checksum
How to use checksums
a7c473c0d1214c5f798f00b16d033cfd866e398a5c8b56f43f989b6bd73da64b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Release files / devkanan-0.2.2-py3-none-any.whl

Download URL devkanan-0.2.2-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd95695fa848397b192500a30daaf4d079b9e29be7641d43d68b2fa9ebd2d536
BLAKE2b-256 checksum
How to use checksums
bf1c129e24897dbaf88eb1b8364ebd9847852d1e6703f18d2c2f42e2e4557f9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.10

Security for devkanan 0.2.2

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.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files No provenance

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