use offline_license_validator::{LicenseValidator, storage};
fn main() {
const PUBLIC_KEY: &str = "913d5e19269699e51bcdb5c5a7106c278ef0e0fe92d31b76b6daf5bb00594fcf";
let validator = match LicenseValidator::new(PUBLIC_KEY) {
Ok(v) => v,
Err(e) => {
eprintln!("Failed to initialize validator: {}", e);
return;
}
};
let license = "eyJod2lkIjoiOGI4MzE4MGFhOGY0ZWQwMThjYjI5OTFlMGZmN2U5YjQ5OTk3MTcxNjBkMTVjN2EyMmFkNWJjOTIyNWE4M2M2ZiIsImlzc3VlZF9hdCI6IjIwMjYtMDMtMTJUMTQ6MTc6NTMuNjUyNTY1WiIsImV4cGlyZXNfYXQiOiIyMDI3LTAzLTA5VDIzOjU5OjU5WiIsImxpY2Vuc2VfdHlwZSI6IlBSTyIsIm1ldGFkYXRhIjpudWxsfQ==.TKdSEvRL79kPQ1qfMr7Xla+Y+TNdLTNA/yPiaLhFpwuV1jMDnT1pQ4//9oLhw5HIp6Xh1S0miPudgE1DtG0eAA==";
let hwid = "8b83180aa8f4ed018cb2991e0ff7e9b4999717160d15c7a22ad5bc9225a83c6f";
match validator.validate(license, hwid) {
Ok(info) => {
println!("✅ License is VALID!");
println!(" Type: {}", info.license_type);
println!(" Issued: {}", info.issued_at);
println!(" Expires: {}", info.expires_at);
println!(" HWID: {}", info.hwid);
if let Err(e) = storage::save_license(&info, license) {
eprintln!("Warning: Could not save license: {}", e);
} else {
println!("\n💾 License saved to ~/.offline-license/");
}
}
Err(e) => {
eprintln!("❌ License is INVALID: {}", e);
}
}
println!("\n--- Checking for cached license ---");
match storage::load_saved_license() {
Ok(Some((saved_license, info))) => {
println!("Found cached license:");
println!(" Type: {}", info.license_type);
println!(" Expires: {}", info.expires_at);
}
Ok(None) => {
println!("No cached license found");
}
Err(e) => {
eprintln!("Error loading cached license: {}", e);
}
}
}