api_keys_simplified/
lib.rs

1//! # API Keys Simplified
2//!
3//! Secure API key generation and validation with sensible defaults.
4//!
5//! ## Quick Start
6//!
7//! ```rust
8//! use api_keys_simplified::{ApiKey, Environment};
9//!
10//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
11//! // Generate a new key
12//! let key = ApiKey::generate_default("sk", Environment::production())?;
13//! println!("Key: {}", key.key().as_ref()); // Show once to user
14//! let hash = key.hash(); // Store this in database
15//!
16//! // Validate a key
17//! let is_valid = ApiKey::verify(key.key(), hash)?;
18//! assert!(is_valid);
19//! # Ok(())
20//! # }
21//! ```
22
23mod config;
24mod domain;
25mod error;
26mod generator;
27mod hasher;
28mod secure;
29mod validator;
30
31pub use config::{Environment, HashConfig, KeyConfig, KeyPrefix, Separator};
32pub use domain::ApiKey;
33pub use error::{Error, Result};
34pub use secure::SecureString;