include_crypt_bytes/
lib.rs

1//! Procedural macro to embed encrypted binary data in compiled binaries.
2//!
3//! The macro works similarly to [`std::include_str`], but instead of embedding the UTF-8
4//! string, it embeds encrypted `[u8]` array. Encryption uses the [chacha20poly1305][1] crate.
5//!
6//! # Examples
7//!
8//! ```rust
9//! # use include_crypt_bytes::include_bytes_crypt;
10//! # let password = "The password to use at runtime to decrypt";
11//! // CONFIG_PASSWORD is the environment variable set to the
12//! // string used to encrypt the contents of the file config.toml
13//! // at compile time
14//! //
15//! // `password` is the variable used to decrypt the embedded data
16//! // at runtime.
17//! let file_bytes = include_bytes_crypt!(
18//!                     "config.toml",
19//!                     password.as_bytes(),
20//!                     "CONFIG_PASSWORD");
21//! ```
22//!
23//! Sometimes, its useful just to obfuscate the embedded data. In that case just the file name is required
24//!
25//! ```rust
26//! # use include_crypt_bytes::include_bytes_obfuscate;
27//! // A random password is generated at compiled time
28//! let file_bytes = include_bytes_obfuscate!("config.toml");
29//! ```
30//!
31//! [1]: https://docs.rs/chacha20poly1305
32pub use include_crypt_bytes_cipher::{decrypt_bytes, encrypt_bytes, CryptError};
33pub use include_crypt_bytes_macro::{include_bytes_crypt, include_bytes_obfuscate};