licensekey2
Installation
pip install licensekey2
Usage
API license keys
Keys is generated and verifyed on the server.
from licensekey2 import RemoteLicense
license = RemoteLicense("https://example.com/api/license")
# Check if the license is valid
license.validate("1234-5678-9012-3456")
Crypto license keys
from datetime import datetime
from licensekey2 import CryptoLicense
# Generate keys. Private key MUST BE kept secret.
public_key, private_key = CryptoLicense.generate_key_pair()
print(public_key, private_key)
# Initialize license object
license = CryptoLicense(public_key, private_key)
# Prepare license subject
license_data = {
"name": "John Doe",
"product": "My Product",
"type": "Ultimate License"
}
# Generate key
key = license.generate_key({}, until=datetime(2025, 1, 1))
print(key)
# Check key and return our license_data
license_subject = license.validate(key)
# Check license type
if license_subject["type"] == "Ultimate License":
print("You have an ultimate license!")
Custom checkers
def custom_checker(license_subject):
if license_subject["type"] == "Ultimate License":
return
raise ValueError("You don't have an ultimate license!")
license = CryptoLicense(public_key, private_key, custom_checker=custom_checker)
key = license.generate_key({"type": "Ultimate License"}, until=datetime(2025, 1, 1))
license.validate(key)
# Key is valid
key = license.generate_key({"type": "Another license"}, until=datetime(2025, 1, 1))
license.validate(key)
# Key is invalid. ValueError raised.
Authors and license
Licensed under the MIT license.
First version by Marat Budkevich (@marat2509)
This version by Egor Ternovoy cofob@riseup.net (@cofob)
Metadata
Release files for licensekey2 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| licensekey2-0.1.0.tar.gz | 6.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| licensekey2-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.3 kB
Release files / licensekey2-0.1.0.tar.gz
| Download URL | licensekey2-0.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
81cca6ce237457406744ef7aa45bac4b7a4aa52e33b0c9fc89c1e8735752a302
|
|
BLAKE2b-256 checksum How to use checksums |
e31eca3e7a15a7dc8d90466a1b76e61e87f1a570ddd64c543df39be00d75bf60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.6 Linux/6.0.2
|
Release files / licensekey2-0.1.0-py3-none-any.whl
| Download URL | licensekey2-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf7d1aef206466994e74db0ddddf4d4debfe8d134f0eb1bbcc7f916f2f715f54
|
|
BLAKE2b-256 checksum How to use checksums |
b5bb642156aec32feab2fc6df467187bcdc589b2712a9fdb64fff4a6e1aebf1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.6 Linux/6.0.2
|
Security for licensekey2 0.1.0
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.