Macro include_crypt::include_crypt [−][src]
Macro that can be used to safely embed files into the binary.
Parameters
The macro can be used with different encryption algorithms.
ⓘ
include_crypt!($encryption_type, $file_path, $optional_key)
$encryption_type: The type of the encryption. EitherXORorAES. If you don't specify an encryption type,XORwill be used.$file_path: The path to the file that should be embedded. If the path is relative, theCARGO_MANIFEST_DIRwill be used as a starting point.$optional_key: The optional encryption key. If specified, it has to be decodable by hex crate.
Returns
The macro expands to a encrypt_xor or encrypt_aes proc macro call. The
return value will then be used to create a new EncryptedFile instance.
Examples
More examples can be found in the tests and examples directory.
// Encrypt using XOR with random key let file: EncryptedFile = include_crypt!("src/lib.rs"); // Encrypt using XOR with custom key let file: EncryptedFile = include_crypt!("src/lib.rs", 0xdeadbeef); // Encrypt using XOR with random key let file: EncryptedFile = include_crypt!(XOR, "src/lib.rs"); // Encrypt using XOR with custom key let file: EncryptedFile = include_crypt!(XOR, "src/lib.rs", 0xdeadbeef); // Encrypt using AES with random key let file: EncryptedFile = include_crypt!(AES, "src/lib.rs"); // Encrypt using AES with custom key let file: EncryptedFile = include_crypt!(AES, "src/lib.rs", 0xdeadbeef);
You can also use absolute paths:
ⓘ
let file: EncryptedFile = include_crypt!("D:/file.txt");