Skip to content
Example of verifying a license key's authenticity using RSA-SHA256 with various padding schemes
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
main.py
requirements.txt

README.md

Example Python Cryptographic Verification

This is an example of cryptographically verifying a license key's authenticity using your Keygen account's public key. You can find your public key within your account's settings page.

This example implements the RSA_2048_PKCS1_SIGN and RSA_2048_PKCS1_PSS_SIGN policy schemes. Cryptographically verifying schemed licenses can be used to implement offline licensing, as well as to add additional security measures to your licensing model. All that is needed to cryptographically verify a license is your account's public key.

Running the example

First up, add an environment variable containing your public key:

# Your Keygen account's public key (make sure it is *exact* - newlines and all)
export KEYGEN_PUBLIC_KEY=$(printf %b \
  '-----BEGIN PUBLIC KEY-----\n' \
  'zdL8BgMFM7p7+FGEGuH1I0KBaMcB/RZZSUu4yTBMu0pJw2EWzr3CrOOiXQI3+6bA\n' \
  #
  'efK41Ml6OwZB3tchqGmpuAsCEwEAaQ==\n' \
  '-----END PUBLIC KEY-----')

You can either run each line above within your terminal session before starting the app, or you can add the above contents to your ~/.bashrc file and then run source ~/.bashrc after saving the file.

Next, install dependencies with pip:

pip install -r requirements.txt

Then run the script, passing in the scheme and key as arguments:

python main.py "{LICENSE_SCHEME}" "{SIGNED_LICENSE_KEY}"

The license key's authenticity will be verified using RSA-SHA256 with the given padding scheme. Be sure to copy your public key and license key correctly - your keys will fail validation if these are copied or included incorrectly. You can find your public key in your account's settings.

Questions?

Reach out at support@keygen.sh if you have any questions or concerns!

You can’t perform that action at this time.