extensible_encrypter/
lib.rs

1//! # Usage
2//!
3//! This is the current E2E test that performs encryption and decryption using the `extensible_encrypter` crate.
4//!
5//! ```
6//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
7//! use extensible_encrypter::prelude::*;
8//!
9//! let plaintext = "secret nuke codes go inside the football";
10//!
11//! let provider = encrypter::Aes256GcmSivEncryptProvide;
12//! let mut cipher_config = encrypter::Aes256GcmSivConfig::default();
13//! cipher_config.set_hash_rounds(20); // low number of rounds for testing
14//!
15//! let result = encrypter::Encrypter::encrypt(
16//!     plaintext,
17//!     "password",
18//!     provider,
19//!     encrypter::Cipher::Aes256GcmSiv(cipher_config),
20//! );
21//! let result = result.expect("Encryption failed");
22//! tracing::info!("Result: {:?}", result);
23//!
24//! let input = &mut DecrypterBuilder::new()
25//!     .salt(result.salt)
26//!     .nonce(result.nonce)
27//!     .ciphertext(result.ciphertext)
28//!     .build();
29//!
30//! let provider = decrypter::PBKDF2DecryptProvide;
31//! let mut cipher_config = decrypter::Aes256GcmSivConfig::default();
32//! cipher_config.set_hash_rounds(20); // low number of rounds for testing
33//!
34//! let result = decrypter::Decrypter::decrypt(
35//!     input,
36//!     provider,
37//!     decrypter::DecrypterCipher::Aes256GcmSiv(cipher_config),
38//! );
39//!
40//! assert_eq!(
41//!     result?.plaintext(),
42//!     "secret nuke codes go inside the football"
43//! );
44//!
45//! # Ok(())
46//! # }
47//! ```
48
49pub mod decrypter;
50pub mod encrypter;
51pub mod error;
52pub mod hasher;
53
54#[allow(unused_imports)]
55pub mod prelude {
56    pub use crate::decrypter::{
57        self, builder,
58        builder::{Decrypter as DecryptData, DecrypterBuilder, DecrypterPayload},
59    };
60    pub use crate::encrypter;
61}