include-crypt-bytes

Crates.ioinclude-crypt-bytes
lib.rsinclude-crypt-bytes
version0.1.3
sourcesrc
created_at2022-07-31 09:27:59.057225
updated_at2022-11-23 05:39:01.55804
descriptionRust macro to embed encrypted files in compiled binary
homepage
repositoryhttps://github.com/breakpointninja/include-crypt-bytes
max_upload_size
id636046
size5,563
Rahul (breakpointninja)

documentation

README

include-crypt-bytes

Procedural macro to embed encrypted binary data in compiled binaries.

The macro works similarly to [std::include_str], but instead of embedding the UTF-8 string, it embeds encrypted [u8] array. Encryption uses the chacha20poly1305 crate.

Examples

// CONFIG_PASSWORD is the environment variable set to the
// string used to encrypt the contents of the file config.toml
// at compile time
//
// `password` is the variable used to decrypt the embedded data
// at runtime.
let file_bytes = include_bytes_crypt!(
                    "config.toml",
                    password.as_bytes(),
                    "CONFIG_PASSWORD");

Sometimes, its useful just to obfuscate the embedded data. In that case just the file name is required

// A random password is generated at compiled time
let file_bytes = include_bytes_obfuscate!("config.toml");

License: MIT OR Apache-2.0

Commit count: 12

cargo fmt