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§
- License
Generator - License key generator that creates time-based license keys
- License
Info - Information about a validated license
- License
Validator - License key validator for offline validation
Enums§
- License
Error - 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