Encrypt strings with the lc! macro
masterTo protect strings from static analysis, use the lc! macro. This encrypts strings at compile time using a basic XOR method, keeping them encrypted in both disk and memory during runtime.
Setup Steps:
- Set the encryption key: Before compiling, you must set the
LITCRYPT_ENCRYPT_KEYenvironment variable. This key is used to encrypt your literal strings and is itself encrypted to remain hidden from static analyzers. - Initialize the macro: Call the
use_litcrypt!()macro at the top of your crate to initialize the encryption logic. - Use the macro: Wrap your plain text strings in the
lc!macro.
Example Usage:
#[macro_use]
extern crate litcrypt;
use_litcrypt!();
fn main(){
// The string "Voldemort" will be encrypted at compile time
println!("his name is: {}", lc!("Voldemort"));
}#[macro_use]
extern crate litcrypt;
use_litcrypt!();
fn main(){
println!("his name is: {}", lc!("Voldemort"));
}