Skip to main content

Crate alvan_lic

Crate alvan_lic 

Source
Expand description

§alvan-lic

A Rust crate for generating and validating time-based license keys with offline validation.

§Features

  • Generate license keys with custom expiration times
  • Validate license keys offline using HMAC
  • Keys always start with “alvan-”
  • Secure against tampering using cryptographic signatures

§Example

use alvan_lic::{LicenseGenerator, LicenseValidator};

// Create a generator with your secret key
let secret_key = "your-super-secret-key";
let generator = LicenseGenerator::new(secret_key);

// Generate a license valid for 24 hours
let license_key = generator.generate_key(24).unwrap();
println!("Generated license: {}", license_key);

// Validate the license
let validator = LicenseValidator::new(secret_key);
match validator.validate_key(&license_key) {
    Ok(info) => println!("License is valid until: {}", info.expires_at),
    Err(e) => println!("License validation failed: {}", e),
}

Structs§

LicenseGenerator
License key generator that creates time-based license keys
LicenseInfo
Information about a validated license
LicenseValidator
License key validator for offline validation

Enums§

LicenseError
Errors that can occur during license generation or validation

Constants§

LICENSE_PREFIX
The prefix for all license keys

Type Aliases§

Result
Result type alias for license operations