Skip to main content

Crate offline_license_validator

Crate offline_license_validator 

Source
Expand description

§Offline License Validator

A simple, secure offline license validation library using Ed25519 signatures.

§Features

  • Ed25519 Cryptography: Industry-standard signature verification
  • HWID Binding: Licenses are bound to specific hardware
  • Expiration Checking: Automatic expiration validation
  • Persistent Storage: Saves validated licenses to ~/.offline-license/
  • Easy Integration: Simple API - just provide public key

§Quick Start

use offline_license_validator::{LicenseValidator, storage};

// Initialize validator with your public key
let validator = LicenseValidator::new(
    "913d5e19269699e51bcdb5c5a7106c278ef0e0fe92d31b76b6daf5bb00594fcf"
).expect("Invalid public key");

// Validate license
match validator.validate("license_string_here", "hardware_id_here") {
    Ok(info) => {
        println!("✓ Valid license!");
        println!("Type: {}", info.license_type);
        println!("Expires: {}", info.expires_at);

        // Save to disk for offline use
        storage::save_license(&info, "license_string_here").ok();
    }
    Err(e) => eprintln!("✗ Invalid license: {}", e),
}

§Storage

Validated licenses are automatically saved to:

  • Unix/macOS: ~/.offline-license/license.json
  • Windows: %USERPROFILE%\.offline-license\license.json

§Security

  • Public key is hardcoded in your application
  • Ed25519 signatures prevent tampering
  • HWID binding prevents license sharing
  • No network required for validation

§Integration with Tauri

#[tauri::command]
fn verify_license(license: String, hwid: String) -> Result<String, String> {
    let validator = LicenseValidator::new(PUBLIC_KEY)
        .map_err(|e| e.to_string())?;

    let info = validator.validate(&license, &hwid)
        .map_err(|e| e.to_string())?;

    storage::save_license(&info, &license).ok();

    Ok(format!("Valid until: {}", info.expires_at))
}

§Credits

Developed by Krakiun - Expert Software Development & Security Solutions

Need custom licensing solutions? Visit krakiun.com

Re-exports§

pub use types::LicensePayload;
pub use types::ValidLicenseInfo;
pub use validator::LicenseError;
pub use validator::LicenseValidator;

Modules§

storage
types
validator