#encryption

cryptify

A procedural macro library to obfuscate Rust code. Provides compile-time string encryption and random flow obfuscation.

6 stable releases

3.1.1 Feb 1, 2024
3.1.0 Jan 10, 2024
3.0.8 Jan 10, 2024
2.0.0 Jan 10, 2024
1.0.0 Jan 9, 2024

#404 in Cryptography

Download history 2/week @ 2024-07-11 12/week @ 2024-07-18 22/week @ 2024-07-25 12/week @ 2024-08-01 23/week @ 2024-08-08 11/week @ 2024-08-15 12/week @ 2024-08-22 49/week @ 2024-08-29 69/week @ 2024-09-05 41/week @ 2024-09-12 36/week @ 2024-09-19 41/week @ 2024-09-26 26/week @ 2024-10-03 44/week @ 2024-10-10 144/week @ 2024-10-17 201/week @ 2024-10-24

424 downloads per month

MIT license

5KB

cryptify

cryptify is a procedural macro crate for compile-time rust obfuscation. It provides the user with string encryption and compile-time determined flow obfuscation and random variables which survive compile-time optimization.

rust-obfuscator - Check out this auto obfuscator tool for easier usage and integration

Features

  • String Obfuscation: Automatically encrypts string literals in your code at compile time, making them harder to read and understand.
  • Flow Obfuscation: Introduces dummy loops and random variables into control flows, enhancing the overall obfuscation of the logic.

Usage

Bring macro into scope

use cryptify;

fn main(){
    let decrypted = cryptify::encrypt_string("Hello, World!");
    println!(decrypted);
    println!("{}", cryptify::encrypt_string!("formatted!"));
}

Set the CRYPTIFY_KEY environment variable for custom encryption otherwise it defaults to defined fixed key

Output

Hello World!
formatted!

Example of expanded Flow_Stmt!

    {
        let _is_dummy_145 = true;
        let _dummy_upper_bound = 100;
        let _dummy_increment = 1i32;
        let mut _dummy_counter = 10i32;
        let _extra_dummy_var = 2i32;
        loop {
            if _dummy_counter > _dummy_upper_bound {
                break;
            }
            unsafe {
                std::ptr::write_volatile(
                    &mut _dummy_counter,
                    _dummy_counter + _dummy_increment,
                );
            }
        }
    };
    match (&1, &1) {
        (left_val, right_val) => {
            if !(*left_val == *right_val) {
                let kind = ::core::panicking::AssertKind::Eq;
                ::core::panicking::assert_failed(
                    kind,
                    &*left_val,
                    &*right_val,
                    ::core::option::Option::None,
                );
            }
        }
    };

License

cryptify is licensed under the MIT License - see the LICENSE file for details.

Dependencies

~0.5–1MB
~23K SLoC