CryptoLion SDK

Secure license management for desktop applications with C and Python bindings

Version 1.3.0
Python 3.6+
C99

Core Features

License Management

Generate, validate, and manage software licenses with expiration control and activation status.

  • Create licenses with custom durations
  • Check license validity in real-time
  • Track creation and expiration dates
  • Activation status management

User Management

Admin-controlled user system with role-based permissions and secure authentication.

  • Create admin and regular users
  • Secure password handling
  • Role-based permissions
  • User ID tracking

Security

Enterprise-grade security features to protect your licensing system.

  • Secure API communication
  • Memory-safe operations
  • Proper resource cleanup
  • Encrypted license keys

SDK Installation

C SDK
Python SDK

C SDK Installation

Requirements: libcurl, cJSON

Terminal
# Clone the repository
git clone https://github.com/cryptolion/sdk.git
cd sdk/c

# Build the library
make

# Install system-wide (optional)
sudo make install

# Link in your project
gcc your_app.c -lcurl -lcjson -lcryptolion -o your_app

Python SDK Installation

Requirements: Python 3.6+, ctypes

Terminal
# Install via pip
pip install cryptolion-sdk

# Or from source
git clone https://github.com/cryptolion/sdk.git
cd sdk/python
python setup.py install

Python SDK Usage

Python API

create_license()

Create a new license (Admin only). Returns a dictionary with license details.

  • username Admin username
  • password Admin password
  • duration_days License duration in days
  • user_id Optional user ID to associate (default: 0)
example.py
from cryptolion import create_license

license = create_license("admin", "securepass", 365)
print(f"Created license: {license['license_key']}")
print(f"Expires at: {license['expires_at']}")

check_license()

Check license validity. Returns a dictionary with license details.

  • license_key License key to validate
example.py
from cryptolion import check_license

license = check_license("LIC-12345-ABCDE")
if license['is_active']:
    print("License is valid!")
else:
    print("License expired or invalid")

create_user()

Create a new user (Admin only). Returns True on success.

  • admin_user Admin username
  • admin_pass Admin password
  • username New user's username
  • password New user's password
  • is_admin Admin privileges flag (default: False)
example.py
from cryptolion import create_user

success = create_user("admin", "securepass", 
                     "newuser", "userpass", False)
if success:
    print("User created successfully")

C SDK Usage

C API

create_license()

Create a new license (Admin only). Returns a License struct.

  • username Admin username
  • password Admin password
  • duration_days License duration in days
  • user_id User ID to associate (0 for none)
example.c
// Create a license valid for 1 year
License lic = create_license("admin", "securepass", 365, 0);
printf("Created license: %s\n", lic.license_key);
printf("Expires at: %s\n", lic.expires_at);

// Free memory when done
free_license(&lic);

check_license()

Check license validity. Returns a License struct.

  • license_key License key to validate
example.c
License lic = check_license("LIC-12345-ABCDE");
if(lic.is_active) {
    printf("Valid license until %s\n", lic.expires_at);
} else {
    printf("License is inactive\n");
}
free_license(&lic);

create_user()

Create a new user (Admin only). Returns 1 on success.

  • admin_user Admin username
  • admin_pass Admin password
  • username New user's username
  • password New user's password
  • is_admin Admin privileges flag (1 or 0)
example.c
int result = create_user("admin", "securepass",
                          "newuser", "userpass", 0);
                          
if(result) {
    printf("User created successfully\n");
} else {
    printf("User creation failed\n");
}

Security Best Practices

Credential Security

  • Never hardcode credentials in your application
  • Use environment variables for sensitive data
  • Implement secure credential storage mechanisms
  • Rotate API credentials regularly

Memory Management

  • Always call free_license() after use
  • Check for NULL pointers before use
  • Validate all input parameters
  • Handle memory allocation failures gracefully

Network Security

  • Always use HTTPS for API communication
  • Verify server certificates
  • Implement request timeout handling
  • Use secure connection protocols (TLS 1.2+)

Python SDK Structure

cryptolion.py
import ctypes
import os
import sys

# Define the License structure
class License(ctypes.Structure):
    _fields_ = [
        ("license_key", ctypes.c_char_p),
        ("created_at", ctypes.c_char_p),
        ("expires_at", ctypes.c_char_p),
        ("is_active", ctypes.c_int)
    ]

# Load the shared library
def load_library():
    # Platform-specific library loading
    if sys.platform.startswith('win'):
        lib_name = "LibLion64.dll"
    elif sys.platform == 'darwin':
        lib_name = "LibLion.dylib"
    else:
        lib_name = "LibLion.so"
    
    try:
        return ctypes.CDLL(lib_name)
    except OSError:
        lib_path = os.path.join(os.path.dirname(__file__), lib_name)
        return ctypes.CDLL(lib_path)

lib = load_library()

# Set function prototypes
lib.create_license.argtypes = [ctypes.c_char_p, ctypes.c_char_p, 
                               ctypes.c_int, ctypes.c_int]
lib.create_license.restype = License

# Python wrapper for create_license
def create_license(username, password, duration_days, user_id=0):
    lic = lib.create_license(
        username.encode('utf-8'),
        password.encode('utf-8'),
        duration_days,
        user_id
    )
    
    result = {
        'license_key': lic.license_key.decode() if lic.license_key else None,
        'created_at': lic.created_at.decode() if lic.created_at else None,
        'expires_at': lic.expires_at.decode() if lic.expires_at else None,
        'is_active': bool(lic.is_active)
    }
    
    # Free C memory
    lib.free_license(ctypes.byref(lic))
    return result