modern_crypto_toolkit/lib.rs
1//! Modern Cryptography & Hashing Toolkit (Rust)
2//!
3//! A misuse-resistant, high-level cryptography library with safe defaults,
4//! constant-time verification, and clear APIs for hashing, password hashing,
5//! key derivation, symmetric encryption, HMAC, and digital signatures.
6//!
7//! # Sub-modules
8//!
9//! - [`hash`]: deterministic hashing and HMAC
10//! - [`password`]: password hashing, verification, and key derivation
11//! - [`encrypt`]: AEAD symmetric encryption
12//! - [`sign`]: Ed25519 digital signatures
13//!
14//! # Examples
15//!
16//! ```
17//! use modern_crypto_toolkit::{hash, password, encrypt, sign};
18//!
19//! let sha256 = hash::string("hello world", "sha-256").unwrap();
20//! let mac = hash::hmac("secret-key", "message", "sha-256").unwrap();
21//! assert!(hash::verify_hmac(&mac, "secret-key", "message", "sha-256").unwrap());
22//!
23//! let ph = password::hash("user-password").unwrap();
24//! assert!(password::verify("user-password", &ph).unwrap());
25//!
26//! let salt = b"saltsaltsaltsalt";
27//! let key = password::derive("passphrase", salt, 32, Some("pbkdf2_sha256"), None).unwrap();
28//!
29//! let ciphertext = encrypt::encrypt_string("sensitive data", &key, None).unwrap();
30//! let plaintext = encrypt::decrypt_string(&ciphertext, &key, None).unwrap();
31//! assert_eq!(plaintext, "sensitive data");
32//!
33//! let (sk, pk) = sign::generate_keypair().unwrap();
34//! let signature = sign::ed25519("message", &sk).unwrap();
35//! assert!(sign::verify(&signature, "message", &pk).unwrap());
36//! ```
37
38pub mod encrypt;
39pub mod error;
40pub mod hash;
41pub mod password;
42pub mod sign;
43
44pub use error::{Error, Result};