Expand description
§API Keys Simplified
Secure API key generation and validation with sensible defaults.
§Quick Start
use api_keys_simplified::{ApiKey, Environment};
// Generate a new key
let key = ApiKey::generate_default("sk", Environment::production())?;
println!("Key: {}", key.key().as_ref()); // Show once to user
let hash = key.hash(); // Store this in database
// Validate a key
let is_valid = ApiKey::verify(key.key(), hash)?;
assert!(is_valid);Structs§
- ApiKey
- Represents a generated API key with its hash.
- Hash
Config - KeyConfig
- KeyPrefix
- Secure
String - A secure string that automatically zeros its memory on drop.
Enums§
- Environment
- Deployment environment for API keys (dev/test/staging/live). Used to visually distinguish keys across different environments and prevent accidental misuse And allow users to set different Rate limits based on Environment.
- Error
- Error type for API key operations.
- Separator
- Separator character for API key components (prefix, environment and data).