Python tools for Keygen.sh licensing
Project description
kgt
Some handy tools for the Keygen licensing service. (This is a user contribution, not an official Keygen LLC product. For Keygen software, see here.)
Install with
pip install kgt
and use as
import sys
from kgt import get_online_license_info, ValidationError
info = get_online_license_info(
account_id="demo", key="DEMO-DAD877-FCBF82-B83D5A-03E644-V3"
)
The out
object contains useful information such as
out.code
out.timestamp
out.license_creation_time
out.license_expiry_time
The validation result can also be safely cached with
import sys
from datetime import datetime, timedelta
from kgt import get_cached_license_info, ValidationError
infi = get_cached_license_info(
account_id="your accound id",
key="the license key",
keygen_verify_key="your Ed25519 128-bit Verify Key",
cache_path="/tmp/license-cache.json",
refresh_cache_period=timedelta(days=3),
)
now = datetime.utcnow()
cache_age = now - out.timestamp
if cache_age > timedelta(days=3) and cache_age < timedelta(days=7):
print("Warning: Could not validate license. Make sure to get online soon.")
elif cache_age > timedelta(days=7):
print("Error: Could not validate license. Internet connection needed. Exiting.")
sys.exit(1)
For offline validation, use
from kgt import get_offline_license_info
# or "RSA_2048_PKCS1_SIGN_V2", "RSA_2048_PKCS1_PSS_SIGN_V2":
license_scheme = "ED25519_SIGN"
keygen_verify_key = "your public verify key"
license_key = "your offline license key"
info = get_offline_license_info(license_scheme, license_key, keygen_verify_key)
print(info)
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
kgt-0.4.4.tar.gz
(27.0 kB
view hashes)
Built Distribution
kgt-0.4.4-py3-none-any.whl
(54.4 kB
view hashes)