Skip to main content

Python tools for Keygen.sh licensing

Project description

kgt

PyPi Version PyPI pyversions

Code style: black

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

kgt-0.4.7-py3-none-any.whl (54.4 kB view details)

Uploaded Python 3

File details

Details for the file kgt-0.4.7-py3-none-any.whl.

File metadata

  • Download URL: kgt-0.4.7-py3-none-any.whl
  • Upload date:
  • Size: 54.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kgt-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1e235b79c7e57b608726c87d9bd5197e06a1a5c8219d2bf4052550e219498af6
MD5 1c675bfac7739b06bc9383692d6d9ba7
BLAKE2b-256 c0c523431d9198ff90ae8b57b84c4e12568fef5007fd614f8550529f609d8f10

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page