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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
use TokenStream;
use parse_macro_input;
use crate;
use crate;
/// Encrust a literal value before it is included in the binary.
///
/// Currently integers, strings and arrays of integers are accepted. Arrays can be
/// nested arbitrarily deep.
///
/// Integers require their data type suffixed (`-1i8`, `127u16` etc).
///
/// # Examples
/// ```
/// # extern crate encrust_core as encrust;
/// # use encrust_macros::encrust;
/// let mut num = encrust!(0u8);
/// assert_eq!(0u8, *num.decrust());
/// let mut string = encrust!("This is a string");
/// assert_eq!("This is a string", &*string.decrust());
/// let mut array = encrust!([1i32, 2i32, 3i32]);
/// assert_eq!(&[1i32, 2i32, 3i32], &*array.decrust());
/// ```
/// Read the contents of a file into a string and encrust it before it is included in the binary.
///
/// Unless an absolute path is given, the file is read relative to the `CARGO_MANIFEST_DIR`
/// environment variable, which is set to the directory containing the crate's `Cargo.toml` file.
/// *Note* that this is not identical to `include_str!`'s behavior, which reads relative to the file
/// using the macro.
///
/// # Example
/// ```
/// # extern crate encrust_core as encrust;
/// # use encrust_macros::encrust_file_string;
/// let mut cargo_toml = encrust_file_string!("Cargo.toml");
/// ```
/// Read the contents of a file into a `CString` and encrust it before it is included in the binary.
///
/// Unless an absolute path is given, the file is read relative to the `CARGO_MANIFEST_DIR`
/// environment variable, which is set to the directory containing the crate's `Cargo.toml` file.
/// *Note* that this is not identical to `include_str!`'s behavior, which reads relative to the file
/// using the macro.
///
/// # Example
/// ```
/// # extern crate encrust_core as encrust;
/// # use encrust_macros::encrust_file_cstring;
/// let mut cargo_toml = encrust_file_cstring!("Cargo.toml");
/// ```
/// Read the contents of a file into a `u8` array and encrust it before it is included in the
/// binary.
///
/// Unless an absolute path is given, the file is read relative to the `CARGO_MANIFEST_DIR`
/// environment variable, which is set to the directory containing the crate's `Cargo.toml` file.
/// *Note* that this is not identical to `include_bytes!`'s behavior, which reads relative to the
/// file using the macro.
///
/// # Example
/// ```
/// # extern crate encrust_core as encrust;
/// # use encrust_macros::encrust_file_bytes;
/// let mut cargo_toml = encrust_file_bytes!("Cargo.toml");
/// ```
/// Hash a string so that it can be searched for in the resulting executable without including the
/// actual string. This macro creates a case sensitive `encrust::Hashstring`.
///
/// # Example
/// ```
/// # extern crate encrust_core as encrust;
/// # use encrust_macros::hashstring;
/// let look_for_me = hashstring!("Find me!");
/// assert!(look_for_me == "Find me!");
/// assert!(look_for_me != "fInD Me!");
/// ```
/// Similar to the [`hashstring!`] macro, but with a case insensitive `encrust::Hashstring`.
///
/// # Example
/// ```
/// # extern crate encrust_core as encrust;
/// # use encrust_macros::hashstring_ci;
/// let look_for_me = hashstring_ci!("Find me!");
/// assert!(look_for_me == "Find me!");
/// assert!(look_for_me == "fInD Me!");
/// ```
/// Hash an array of bytes so that the byte pattern can be searched for without including the bytes
/// themselves in the executable.
///
/// # Example
/// ```
/// # extern crate encrust_core as encrust;
/// # use encrust_macros::hashbytes;
/// let look_for_me = hashbytes!([0, 1, 2, 3]);
/// assert!(look_for_me == &[0, 1, 2, 3]);
/// ```