Welcome to cryptolens python’s documentation!

class licensing.methods.Key[source]

License key related methods. More docs: https://app.cryptolens.io/docs/api/v3/Key.

static activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return=0, metadata=False, floating_time_interval=0, max_overdraft=0, friendly_name=None)[source]

Calls the Activate method in Web API 3 and returns a tuple containing (LicenseKey, Message). If an error occurs, LicenseKey will be None. If everything went well, no message will be returned.

More docs: https://app.cryptolens.io/docs/api/v3/Activate

add_feature(product_id, key, feature)[source]

This method will set a certain feature (F1..F8) to true. If the key algorithm in the product is SKGL, the key string will be changed if necessary. Otherwise, if SKM15 is used, the key will stay the same. To do the reverse, please see RemoveFeature.

More docs: https://app.cryptolens.io/docs/api/v3/AddFeature

block_key(product_id, key)[source]

This method will block a specific license key to ensure that it will no longer be possible to activate it. Note, it will still be possible to access the license key using the GetKey method. To do the reverse, you can use the Unblock Key method.

More docs: https://app.cryptolens.io/docs/api/v3/BlockKey

static change_customer(token, product_id, key, customer_id)[source]

This method will change the customer associated with a license. If the customer is not specified (for example, if CustomerId=0) or the customer with the provided ID does not exist, any customer that was previously associated with the license will be dissociated.

More docs: https://app.cryptolens.io/docs/api/v3/ChangeCustomer

change_notes(product_id, key, notes)[source]

This method will change the content of the notes field of a given license key.

More docs: https://app.cryptolens.io/docs/api/v3/ChangeNotes

change_reseller(product_id, key, reseller_id)[source]

This method will change the reseller of a license. If the reseller is not specified (for example, if ResellerId=0) or the reseller with the provided ID does not exist, any reseller that was previously associated with the license will be dissociated.

More docs: https://app.cryptolens.io/docs/api/v3/ChangeReseller

static create_key(token, product_id, period=0, f1=False, f2=False, f3=False, f4=False, f5=False, f6=False, f7=False, f8=False, notes='', block=False, customer_id=0, new_customer=False, add_or_use_existing_customer=False, trial_activation=False, max_no_of_machines=0, no_of_keys=1, name=None, email=None, company_name=None, enable_customer_association=False, allow_activation_management=False)[source]

This method allows you to create a new license key. The license can either be standalone or associated to a specific customer. It is also possible to add a new customer and associate it with the newly created license using NewCustomer parameter. If you would like to avoid duplicates based on the email, you can use the AddOrUseExistingCustomer parameter.

The parameters “name”, “email”, “company_name”, “enable_customer_association” and “allow_activation_management” are used to create a new customer (or update an existing one) and automatically associate it with the newly created license. Please note that you need to use an access token with both “CreateKey” and “AddCustomer” permissions. Moreover, either the parameter “new_customer” or “add_or_use_existing_customer” need to be set to True.

More docs: https://app.cryptolens.io/docs/api/v3/CreateKey/

create_key_from_template(license_template_id)[source]

This method will create a license key based on a License Template. If you want to see all the defined license templates through the API, this can be accomplished with Get License Templates. An alternative is to call the Create Key method, which allows you to specify all the parameters yourself. Note: the “feature lock” field in the access token can be used to restrict which license tempalte id can be used.

More docs: https://app.cryptolens.io/docs/api/v3/CreateKeyFromTemplate

static create_trial_key(token, product_id, machine_code)[source]

Calls the CreateTrialKey method in Web API 3 and returns a tuple containing (LicenseKeyString, Message). If an error occurs, LicenseKeyString will be None. If everything went well, no message will be returned.

More docs: https://app.cryptolens.io/docs/api/v3/CreateTrialKey

static deactivate(token, product_id, key, machine_code, floating=False)[source]

Calls the Deactivate method in Web API 3 and returns a tuple containing (Success, Message). If an error occurs, Success will be False. If everything went well, Sucess is true and no message will be returned.

More docs: https://app.cryptolens.io/docs/api/v3/Deactivate

static extend_license(token, product_id, key, no_of_days)[source]

This method will extend a license by a certain amount of days. If the key algorithm in the product is SKGL, the key string will be changed if necessary. Otherwise, if SKM15 is used, the key will stay the same. More about the way this method works in Remarks.

More docs: https://app.cryptolens.io/docs/api/v3/ExtendLicense

static get_key(token, rsa_pub_key, product_id, key, fields_to_return=0, metadata=False, floating_time_interval=0)[source]

Calls the GetKey method in Web API 3 and returns a tuple containing (LicenseKey, Message). If an error occurs, LicenseKey will be None. If everything went well, no message will be returned.

More docs: https://app.cryptolens.io/docs/api/v3/GetKey

machine_lock_limit(product_id, key, number_of_machines)[source]

This method will change the maximum number of machine codes that a license key can have.

More docs: https://app.cryptolens.io/docs/api/v3/MachineLockLimit

remove_feature(product_id, key, feature)[source]

This method will set a certain feature (F1..F8) to false. If the key algorithm in the product is SKGL, the key string will be changed if necessary. Otherwise, if SKM15 is used, the key will stay the same. To do the reverse, please see AddFeature.

More docs: https://app.cryptolens.io/docs/api/v3/RemoveFeature

static unblock_key(token, product_id, key)[source]

This method will unblock a specific license key to ensure that it can be accessed by the Key.Activate method. To do the reverse, you can use the BlockKey method.

More docs: https://app.cryptolens.io/docs/api/v3/UnblockKey

class licensing.methods.AI[source]
static get_events(token, limit=10, starting_after=0, product_id=0, key='', metadata='')[source]

This method will retrieve events that were registered using Register event method.

More docs: https://app.cryptolens.io/api/ai/GetEvents

static get_web_api_log(token, product_id=0, key='', machine_code='', friendly_name='', limit=10, starting_after=0, ending_before=0, order_by='')[source]

This method will retrieve a list of Web API Logs. All events that get logged are related to a change of a license key or data object, eg. when license key gets activated or when a property of data object changes. More details about the method that was called are specified in the State field.

More docs: https://app.cryptolens.io/docs/api/v3/GetWebAPILog

static register_event(token, product_id=0, key='', machine_code='', feature_name='', event_name='', value=0, currency='', metadata='')[source]

This method will register an event that has occured in either the client app (eg. start of a certain feature or interaction within a feature) or in a third party provider (eg. a payment has occured, etc).

Note: You can either use this method standalone (eg. by only providing a machine code/device identifier) or together with Cryptolens Licensing module (which requires productId and optionally keyid to be set). The more information that is provided, the better insights can be provided.

More docs: https://app.cryptolens.io/api/ai/RegisterEvent

class licensing.methods.Data[source]

Data object related methods

static add_data_object_to_key(token, product_id, key, name='', string_value='', int_value=0, check_for_duplicates=False)[source]

This method will add a new Data Object to a license key.

More docs: https://app.cryptolens.io/docs/api/v3/AddDataObject (see parameters under Method 2)

static add_data_object_to_machine(token, product_id, key, machine_code, name='', string_value='', int_value=0, check_for_duplicates=False)[source]

This method will add a new Data Object to Machine.

More docs: https://app.cryptolens.io/docs/api/v3/AddDataObject (see parameters under Method 3)

static decrement_int_value_to_key(token, product_id, key, object_id, int_value=0, enable_bound=False, bound=0)[source]

This method will decrement the int value of a data object associated with a license key.

When creating an access token to this method, remember to include “DecrementIntValue” permission and set the “Lock to key” value to -1.

More docs: https://app.cryptolens.io/docs/api/v3/DecrementIntValue (see parameters under Method 2)

static increment_int_value_to_key(token, product_id, key, object_id, int_value=0, enable_bound=False, bound=0)[source]

This method will increment the int value of a data object associated with a license key.

When creating an access token to this method, remember to include “IncrementIntValue” permission and set the “Lock to key” value to -1.

More docs: https://app.cryptolens.io/docs/api/v3/IncrementIntValue (see parameters under Method 2)

static list_key_data_objects(token, product_id, key, name_contains='')[source]

This method will list Data Objects for License Key.

More docs: https://app.cryptolens.io/docs/api/v3/ListDataObjects (see parameters under Method 2)

static list_machine_data_objects(token, product_id, key, machine_code, name_contains='')[source]

This method will list Data Objects for Machine.

More docs: https://app.cryptolens.io/docs/api/v3/ListDataObjects (see parameters under Method 3)

static remove_data_object_to_key(token, product_id, key, object_id=0, name='')[source]

This method will add a new Data Object to a license key.

Note: either an object_id or name (provided there are no duplicates) is required.

More docs: https://app.cryptolens.io/docs/api/v3/RemoveDataObject (see parameters under Method 2)

static remove_data_object_to_machine(token, product_id, key, machine_code, object_id=0, name='')[source]

This method will remove existing Data Object from Machine Code.

More docs: https://app.cryptolens.io/docs/api/v3/RemoveDataObject (see parameters under Method 3)

class licensing.methods.PaymentForm[source]
static create_session(token, payment_form_id, currency, expires, price=None, heading=None, product_name=None, custom_field='', metadata=None)[source]

This method will create a new session for a Payment Form. It allows you to customize appearance of the form (such as price, heading, etc). You should only create new sessions from a server side (i.e. never directly from your application). Note, session will only work once and it will eventually expire depending on Expires parameter.

More docs: https://app.cryptolens.io/docs/api/v3/PFCreateSession

class licensing.methods.Message[source]
create_message(content='', channel='', time=0)[source]

This method will create a new message. This method requires Edit Messages permission.

More docs: https://app.cryptolens.io/docs/api/v3/CreateMessage

static get_messages(token, channel='', time=0)[source]

This method will return a list of messages that were broadcasted. You can create new messages here. Messages can be filtered based on the time and the channel.

More docs: https://app.cryptolens.io/docs/api/v3/GetMessages

remove_message(messageId)[source]

This method will remove a message that was previously broadcasted. This method requires Edit Messages permission.

More docs: https://app.cryptolens.io/docs/api/v3/RemoveMessage

class licensing.methods.Customer[source]
static add_customer(token, name='', email='', company_name='', enable_customer_association=False, allow_activation_management=False)[source]

This method will add new customer.

More docs: https://app.cryptolens.io/docs/api/v3/AddCustomer

static get_customer_licenses(token, customer_id, detailed=False, metadata=False)[source]

This method will return a list of license keys that belong to a certain customer.

More docs: https://app.cryptolens.io/docs/api/v3/GetCustomerLicenses

static get_customer_licenses_by_secret(token, secret, detailed=False, metadata=False)[source]

This method will return a list of license keys that belong to a certain customer.

More docs: https://app.cryptolens.io/docs/api/v3/GetCustomerLicenses

class licensing.methods.Product[source]
static get_keys(token, product_id, page=1, order_by='ID ascending', search_query='')[source]

This method will return a list of keys for a given product. Please keep in mind that although each license key will be of the License Key type, the fields related to signing operations will be left empty. Instead, if you want to get a signed license key (for example, to achieve offline key activation), please use the Activation method instead.

More docs: https://app.cryptolens.io/docs/api/v3/GetKeys

static get_products(token)[source]

This method will return the list of products. Each product contains fields such as the name and description, as well feature definitions and data objects. All the fields of a product are available here: https://app.cryptolens.io/docs/api/v3/model/Product

More docs: https://app.cryptolens.io/docs/api/v3/GetProducts

class licensing.models.LicenseKey(ProductId, ID, Key, Created, Expires, Period, F1, F2, F3, F4, F5, F6, F7, F8, Notes, Block, GlobalId, Customer, ActivatedMachines, TrialActivation, MaxNoOfMachines, AllowedMachines, DataObjects, SignDate, Reseller, RawResponse)[source]
static load_from_string(rsa_pub_key, string, signature_expiration_interval=- 1)[source]

Loads a license from a string generated by save_as_string. Note: if an error occurs, None will be returned. An error can occur if the license string has been tampered with or if the public key is incorrectly formatted.

Parameters

signature_expiration_interval – If the license key was signed,

this method will check so that no more than “signatureExpirationInterval” days have passed since the last activation.

save_as_string()[source]

Save the license as a string that can later be read by load_from_string.

class licensing.methods.Helpers[source]
static GetMACAddress()[source]

An alternative way to compute the machine code (device identifier). This method is especially useful if you plan to target multiple platforms.

static GetMachineCode(v=1)[source]

Get a unique identifier for this device. If you want the machine code to be the same in .NET on Windows, you can set v=2. More information is available here: https://help.cryptolens.io/faq/index#machine-code-generation

Note: if we are unable to compute the machine code, None will be returned. Please make sure to check this in production code.

HasFeature(feature_name)[source]

Uses a special data object associated with the license key to determine if a certain feature exists (instead of the 8 feature flags). <strong>Formatting: </strong> The name of the data object should be ‘cryptolens_features’ and it should be structured as a JSON array.

For example, <pre>[“f1”, “f2”]</pre><p>means f1 and f2 are true. You can also have feature bundling, eg. <pre>[“f1”, [“f2”,[“voice”,”image”]]]</pre> which means that f1 and f2 are true, as well as f2.voice and f2.image. You can set any depth, eg. you can have <pre>[“f1”, [“f2”,[[“voice”,[“all”]], “image”]]]</pre> means f2.voice.all is true as well as f2.voice and f2. The dots symbol is used to specify the “sub-features”.

Read more here: https://help.cryptolens.io/web-interface/feature-templates

Parameters:

@license_key The license key object. @feature_name For example, “f2.voice.all”.

static IsOnRightMachine(license_key, is_floating_license=False, allow_overdraft=False, v=1, custom_machine_code=None)[source]

Check if the device is registered with the license key. The version parameter is related to the one in GetMachineCode method.

class licensing.models.ActivatedMachine(IP, Mid, Time, FriendlyName='', FloatingExpires='')[source]
class licensing.models.Response(license_key, signature, result, message, metadata=None)[source]

Indices and tables