Crate litcrypt[][src]

Expand description

LitCrypt

The name is an abbreviation of ‘Literal Encryption’ – a Rust compiler plugin to encrypt text literals using the XOR cipher.

LitCrypt let’s you hide your static string literal in the binary from naughty eyes and protect your app from illegal cracking activity.

LitCrypt works by encrypting string literals during compile time. An encrypted string remains encrypted both on disk and in memory during runtime. It is decypted only when used.

Usage

In Cargo.toml, add:

[dependencies]
litcrypt = "0.2"

Example

#[macro_use]
extern crate litcrypt;

use_litcrypt!("MY-SECRET-SPELL");

fn main(){
    println!("his name is: {}", lc!("Voldemort"));
}

The use_litcrypt! macro must be called first, for initialization. Its parameter is the secret key that is used to encrypt all lc!-wrapped string literal(s). This key is also encrypted and will not visible in a static analyzer.

Only after that can you use the lc! macro.

You can also override the key using an environment variable LITCRYPT_ENCRYPT_KEY e.g:

❯ export LITCRYPT_ENCRYPT_KEY="myverysuperdupermegaultrasecretkey"

LitCrypt will statically encrypt every string encapsulated in an lc! macro.

Check the output binary using the strings command, e.g:

❯ strings target/debug/my_valuable_app | grep Voldemort

If the output is blank then the resp. strings in your app are safe from a static analyzer tool like a hex editor.

For an example see the ./examples directory:

❯ cargo run --example simple

Macros

Encrypts the resp. string with the key set before, via calling use_litcrypt!.

Sets the encryption key used for encrypting subsequence strings wrapped in a lc! macro.