New: Offline-first licensing with cryptographic validation. Learn more

Quick Start

This guide will walk you through integrating Licenz into your application in under 10 minutes.

Prerequisites

  • A Licenz account (sign up free)
  • Rust 1.70+ (for the client library)
  • Your application ready for license integration

Step 1: Install the Client Library

Add the Licenz client library to your Cargo.toml:

[dependencies]
licenz = "0.1"

Step 2: Create a Product

Log into the Licenz dashboard and create a new product. You'll receive a Product ID and Public Key.

Step 3: Generate a License

Create a license for testing in the dashboard, or use the CLI:

licenz license create \
  --product PRODUCT_ID \
  --email customer@example.com \
  --type subscription \
  --expires 2025-12-31

Step 4: Validate in Your Application

Add license validation to your application's startup:

use licenz::{License, Verifier, PublicKey};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Your public key from the dashboard
    let public_key = PublicKey::from_pem(include_str!("public_key.pem"))?;
    let verifier = Verifier::new(public_key);

    // Load the license (from file, environment, or user input)
    let license_key = std::env::var("LICENSE_KEY")?;
    let license = License::from_key(&license_key)?;

    // Verify the license
    match verifier.verify(&license) {
        Ok(valid) if valid.is_active() => {
            println!("License valid! Features: {:?}", valid.features());
            // Continue with your application
        }
        Ok(valid) => {
            eprintln!("License expired on {}", valid.expires_at());
            std::process::exit(1);
        }
        Err(e) => {
            eprintln!("License validation failed: {}", e);
            std::process::exit(1);
        }
    }

    Ok(())
}

Step 5: Hardware Binding (Optional)

For stronger protection, bind licenses to specific hardware:

use licenz::{License, Verifier, HardwareFingerprint};

// Generate hardware fingerprint on the customer's machine
let fingerprint = HardwareFingerprint::collect()?;

// Include fingerprint in verification
match verifier.verify_with_hardware(&license, &fingerprint) {
    Ok(valid) if valid.hardware_matches() => {
        println!("License valid and hardware verified!");
    }
    Ok(_) => {
        eprintln!("License not valid for this machine");
        std::process::exit(1);
    }
    Err(e) => {
        eprintln!("Validation error: {}", e);
        std::process::exit(1);
    }
}

Next Steps

Need help? Check out our GitHub examples or contact support.