1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
use implementations::{aes, files, xor}; use proc_macro::TokenStream; mod implementations; mod utils; /// Encrypts a file with a random or custom key. /// /// # Example /// /// ## Custom key /// /// ``` /// # use include_crypt_codegen::encrypt_xor; /// let (key, encrypted) = encrypt_xor!("src/lib.rs", 0xdeadbeef); /// ``` /// /// ## Random key /// /// ``` /// # use include_crypt_codegen::encrypt_xor; /// let (key, encrypted) = encrypt_xor!("src/lib.rs"); /// ``` #[proc_macro] pub fn encrypt_xor(input: TokenStream) -> TokenStream { match xor::impl_encrypt_xor(input) { Ok(ts) => ts, Err(err) => err.to_compile_error().into(), } } /// Encrypts a file with a random or custom key. /// /// # Example /// /// ## Custom key /// /// ``` /// # use include_crypt_codegen::encrypt_aes; /// let (key, nonce, encrypted) = encrypt_aes!("src/lib.rs", 0xdeadbeef); /// ``` /// /// ## Random key /// /// ``` /// # use include_crypt_codegen::encrypt_aes; /// let (key, nonce, encrypted) = encrypt_aes!("src/lib.rs"); /// ``` #[proc_macro] pub fn encrypt_aes(input: TokenStream) -> TokenStream { match aes::impl_encrypt_aes(input) { Ok(ts) => ts, Err(err) => err.to_compile_error().into(), } } /// Encrypts all the files in the specified folder. /// /// # Example /// /// ``` /// # use include_crypt_codegen::include_files; /// let files = include_files!("XOR", "src"); /// ``` #[proc_macro] pub fn include_files(input: TokenStream) -> TokenStream { match files::impl_include_files(input) { Ok(ts) => ts, Err(err) => err.to_compile_error().into(), } }