obfustring 0.5.0

Procedural macro that obfuscates string literals with RNG at compile time.
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 11.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 336.43 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Retoon/obfustring
    13 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Retoon

Obfustring

This crate provides a obfuscation macro for string literals. This makes it easy to protect them from common reverse engineering attacks like string reference lookup in something like a debugger or hex editor.

A string literal "" is given as the input and converted into a [u8; str_size*2] array literal that is then stored inside the binary. Every character is offset by a random amount. This offset is stored alongside the original data so it can be reconstructed.

Installation

[dependencies]

obfustring = "0.5.0"

Syntax & Usage

The crate provides a obfustring!() macro that takes in a single string literal.

use obfustring::obfustring;

let obfuscated_string = obfustring!("Hello obfustring!"); // <-- Won't show up in binaries or hex editors
let generic_string = String::from("Hello regular string!"); // <-- Will show up in binaries or hex editors

println!("obfuscated_string: {}", obfuscated_string);
println!("generic_string: {}", generic_string);

Disclaimer

Note that you should never have any encryption/api keys or sensetive data hardcoded into your program. Though this macro would make it harder, it wouldn't absolutely hide it from someone looking hard enough. Stick to environment variables.

License

This project is licensed under the MIT license.