1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! # IronCrypt: A Robust Cryptography Library for Rust
//!
//! IronCrypt provides a high-level, easy-to-use API for common cryptographic tasks,
//! focusing on strong, modern algorithms and secure practices. It is designed to be used
//! both as a command-line tool and as a library integrated into Rust applications.
//!
//! ## Core Features
//!
//! - **Hybrid Encryption:** Combines the speed of AES-256-GCM for data encryption with the
//! security of RSA for key management (envelope encryption).
//! - **State-of-the-Art Password Hashing:** Uses Argon2, a modern, memory-hard algorithm
//! designed to resist GPU-based cracking attempts.
//! - **Comprehensive Data Handling:** Encrypts not just passwords, but also files, directories,
//! and any arbitrary binary data.
//! - **Advanced Key Management:** Supports versioned RSA keys and provides a key rotation
//! mechanism to update keys over time without manual re-encryption.
//! - **Flexible Configuration:** Allows fine-tuning of security parameters like RSA key size,
//! Argon2 costs, and password strength criteria.
//!
//! ## Quick Start: Library Usage
//!
//! Here is a quick example of how to use `IronCrypt` as a library to encrypt and verify a password.
//!
//! ```rust
//! use ironcrypt::{IronCrypt, IronCryptConfig, IronCryptError};
//!
//! fn main() -> Result<(), IronCryptError> {
//! // 1. Initialize IronCrypt with a default configuration.
//! // This will automatically generate a 2048-bit RSA key pair in the "keys/"
//! // directory if it doesn't already exist.
//! let config = IronCryptConfig::default();
//! let crypt = IronCrypt::new("keys", "v1", config)?;
//!
//! // 2. Encrypt a password.
//! let password = "My$ecureP@ssw0rd!";
//! let encrypted_data = crypt.encrypt_password(password)?;
//! println!("Password encrypted successfully!");
//!
//! // 3. Verify the password.
//! let is_valid = crypt.verify_password(&encrypted_data, password)?;
//! assert!(is_valid);
//! println!("Password verification successful!");
//!
//! // 4. Clean up the generated keys for this example.
//! // In a real application, you would not delete your keys.
//! std::fs::remove_dir_all("keys")?;
//!
//! Ok(())
//! }
//! ```
//!
//! For more detailed examples, including file encryption and custom configurations,
//! please see the project's `examples/` directory.
// 1) Module declarations (the files)
// (maps to "config.rs")
// (maps to "criteria.rs")
// (maps to "encrypt.rs")
// (maps to "handle_error.rs")
// (maps to "hashing.rs")
// (maps to "ironcrypt.rs")
// (maps to "rsa_utils.rs")
// 2) Re-export items you want available at the crate root
// The binary (main.rs) can then use `ironcrypt::{ generate_rsa_keys, ... }`
pub use *; // IronCryptConfig, etc.
pub use *; // PasswordCriteria
pub use ; // only explicit items
pub use *; // IronCryptError, etc.
pub use *; // hash_password (if needed)
pub use IronCrypt; // struct IronCrypt
pub use *; // generate_rsa_keys, load_public_key, etc.