|
1 | | - # Staticrypt |
| 1 | +# Staticrypt |
2 | 2 |
|
3 | | - The name is an abbreviation of "Static Encryption" - a Rust proc macro libary to encrypt text |
4 | | - literals or binary data using AES-256. |
| 3 | +The name is an abbreviation of "Static Encryption" - a Rust proc macro library to encrypt text |
| 4 | +literals or binary data using AES-256. |
5 | 5 |
|
6 | | - The crate is intended to be a successor to [`litcrypt`](https://docs.rs/litcrypt/latest/litcrypt/), |
7 | | - and expand on the overall idea of the library. |
| 6 | +The crate is intended to be a successor to [`litcrypt`](https://docs.rs/litcrypt/latest/litcrypt/), |
| 7 | +and expand on the overall idea of the library. |
8 | 8 |
|
9 | | - Like litcrypt, staticrypt works by encrypting the given data at compile time. In its place, it |
10 | | - leaves the encrypted contents and a 96 bit nonce (unique for every encrypted item), protecting |
11 | | - your data from static analysis tools. |
| 9 | +Like litcrypt, staticrypt works by encrypting the given data at compile time. In its place, it |
| 10 | +leaves the encrypted contents and a 96 bit nonce (unique for every encrypted item), protecting |
| 11 | +your data from static analysis tools. |
12 | 12 |
|
13 | | - In contrast to to litcrypt's `lc`, staticrypt's `sc` supports all valid Rust string literals, |
14 | | - including those with escape sequences, unicode characters, etc. |
| 13 | +In contrast to to litcrypt's `lc`, staticrypt's `sc` supports all valid Rust string literals, |
| 14 | +including those with escape sequences, unicode characters, etc. |
15 | 15 |
|
16 | | - To initialize staticrypt in a crate, the `use_staticrypt` macro needs to be called first. See |
17 | | - its doc page for more info on initial setup. |
| 16 | +To initialize staticrypt in a crate, the `use_staticrypt` macro needs to be called first. See |
| 17 | +its doc page for more info on initial setup. |
18 | 18 |
|
19 | | - ## Example |
| 19 | +## Example |
20 | 20 |
|
21 | | - ```rust |
22 | | - use staticrypt::*; |
| 21 | +```rust |
| 22 | +use staticrypt::*; |
23 | 23 |
|
24 | | - // Needs to be present at the root of the crate. |
25 | | - use_staticrypt!(); |
| 24 | +// Needs to be present at the root of the crate. |
| 25 | +use_staticrypt!(); |
26 | 26 |
|
27 | | - fn main() { |
28 | | - // Protect sensitive information from static analysis / tampering |
29 | | - println!("The meaning of life is {}", sc!("42")); |
30 | | - } |
31 | | - ``` |
| 27 | +fn main() { |
| 28 | + // Protect sensitive information from static analysis / tampering |
| 29 | + println!("The meaning of life is {}", sc!("42")); |
| 30 | +} |
| 31 | +``` |
32 | 32 |
|
33 | | - Everything inside the `sc` macro will be encrypted at compile time. You can verify that none |
34 | | - of the strings are present in cleartext using something like `strings`: |
| 33 | +Everything inside the `sc` macro will be encrypted at compile time. You can verify that none |
| 34 | +of the strings are present in cleartext using something like `strings`: |
35 | 35 |
|
36 | | - ```shell |
37 | | - strings target/debug/my_app | grep 42 |
38 | | - ``` |
| 36 | +```shell |
| 37 | +strings target/debug/my_app | grep 42 |
| 38 | +``` |
39 | 39 |
|
40 | | - If the output is blank / does not contain the string you are looking for, then your app is safe |
41 | | - from static analysis tools. |
| 40 | +If the output is blank / does not contain the string you are looking for, then your app is safe |
| 41 | +from static analysis tools. |
42 | 42 |
|
43 | | - ## DISCLAIMER |
| 43 | +## DISCLAIMER |
44 | 44 |
|
45 | | - Although using tools like staticrypt makes it very difficult for attackers to view or alter |
46 | | - your data, it does _not_ make it impossible. You should develop your programs with the |
47 | | - assumption that a sufficiently determined attacker will be able to reverse engineer your |
48 | | - encryption and gain access to any data present in your binary, so it is **highly discouraged** to |
49 | | - use this crate to embed sensitive information like API keys, passwords, private keys etc. in your |
50 | | - application. |
| 45 | +Although using tools like staticrypt makes it very difficult for attackers to view or alter |
| 46 | +your data, it does _not_ make it impossible. You should develop your programs with the |
| 47 | +assumption that a sufficiently determined attacker will be able to reverse engineer your |
| 48 | +encryption and gain access to any data present in your binary, so it is **highly discouraged** to |
| 49 | +use this crate to embed sensitive information like API keys, passwords, private keys etc. in your |
| 50 | +application. |
0 commit comments