Cliente Python para DevKanan — validación local + API online de licencias firmadas RSA
Project description
devkanan
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 authorizedhas_not_expired()— verifiesexpires > nowhas_feature(n)— shortcut forgetattr(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).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file devkanan-0.2.2.tar.gz.
File metadata
- Download URL: devkanan-0.2.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27d5a81da66c130243ab18376f8c3b046a8d365f44513153cef1f625f65acdfc
|
|
| MD5 |
c2b1a3682fb8ea7729d2624edecdf3dd
|
|
| BLAKE2b-256 |
a7c473c0d1214c5f798f00b16d033cfd866e398a5c8b56f43f989b6bd73da64b
|
File details
Details for the file devkanan-0.2.2-py3-none-any.whl.
File metadata
- Download URL: devkanan-0.2.2-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd95695fa848397b192500a30daaf4d079b9e29be7641d43d68b2fa9ebd2d536
|
|
| MD5 |
3fb63bcc467cf4e52f8906ae03faa5b0
|
|
| BLAKE2b-256 |
bf1c129e24897dbaf88eb1b8364ebd9847852d1e6703f18d2c2f42e2e4557f9f
|