Rust crate for obfuscating string literals.

Overview

Obfustring

github crates.io docs.rs license

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 sensitive 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.

You might also like...
An experimental Rust crate for sigstore

Continuous integration Docs License This is an experimental crate to interact with sigstore. This is under high development, many features and checks

Rust on ESP32 STD "Hello, World" app. A "Hello, world!" STD binary crate for the ESP32[XX] and ESP-IDF.

Rust on ESP32 STD "Hello, World" app A "Hello, world!" STD binary crate for the ESP32[XX] and ESP-IDF. This is the crate you get when running cargo ne

Rust-idiomatic, compliant, flexible and performant BIP21 crate

Rust implementation of BIP21 Rust-idiomatic, compliant, flexible and performant BIP21 crate. About Important: while lot of work went into polishing th

Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code.
Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code.

Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code.

Demonstration of how to use the rust object_store crate

Introduction Demonstration of how to use the Rust object_store crate Example

A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library!
A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library!

cabal-pack A tool that helps you to turn in one command a Rust crate into a Haskell Cabal library! To generate bindings, you need to annotate the Rust

Rust crate implementing short & stable ids based on timestamps

Lexicoid Short & stable IDs based on timestamps. Heavily inspired by Short, friendly base32 slugs from timestamps by @brandur. Install Install with ca

c-library wrapper around the rust pdb crate

pdbcrust: pdbcrust is a c-library wrapper around the rust pdb crate. The API only exports a minimum subset of the pdb crate functionality. The project

🦀 Rust crate that allows creating weighted prefix trees that can be used in autocomplete

weighted_trie 🦀 Rust crate that allows creating weighted prefix trees that can be used in autocomplete Released API Docs Quickstart To use weigthed-t

Comments
  • Comply with deterministic compilation concept

    Comply with deterministic compilation concept

    Currently, this library doesn't follow the concept of reproducible builds (a.k.a. deterministic compilation), i'd to comply with this as i belive it would be best practice. A solution to this problem would be to seed the RNG used when making offsets of the original characters.

    See this comment from (one of) the obfstr maintainer(s):

    Your implementation is not compatible with the concept reproducible builds (that is, building the code twice should result in exactly the same binary). This is easily fixable by seeding the rng (I use an env var + file, line, column + hash of the string itself)

    opened by Retoon 0
Owner
null
A crate for converting an ASCII text string or file to a single unicode character

A crate for converting an ASCII text string or file to a single unicode character. Also provides a macro to embed encoded source code into a Rust source file. Can also do the same to Python code while still letting the code run as before by wrapping it in a decoder.

Johanna Sörngård 17 Dec 31, 2022
Stack heap flexible string designed to improve performance for Rust

flexible-string A stack heap flexible string designed to improve performance. FlexibleString was first implemented in spdlog-rs crate, which improved

Sprite 6 Feb 9, 2022
Idiomatic Rust implementations for various Windows string types (like UNICODE_STRING)

nt-string by Colin Finck <[email protected]> Provides idiomatic Rust implementations for various Windows string types: NtUnicodeString (with NtUnicode

Colin Finck 5 Jun 4, 2023
Rust based magic-string with source map chains support

enhanced-magic-string Rust implementation of https://www.npmjs.com/package/magic-string with original sourcemap chain support. license. This project i

Farm 3 Nov 5, 2023
Simple string matching with questionmark- and star-wildcard operator

wildmatch Match strings against a simple wildcard pattern. Tests a wildcard pattern p against an input string s. Returns true only when p matches the

Armin Becher 38 Dec 18, 2022
A special rope, designed to work with any data type that is not String

AnyRope AnyRope is an arbitrary data type rope for Rust, designed for similar operations that a rope would do, but targeted at data types that are not

ahoyiski 27 Mar 22, 2023
Compact, clone-on-write vector and string.

ecow Compact, clone-on-write vector and string. Types An EcoVec is a reference-counted clone-on-write vector. It takes up two words of space (= 2 usiz

Typst 78 Apr 18, 2023
Parses a relative time string and returns a `Duration`

humantime_to_duration A Rust crate for parsing human-readable relative time strings and converting them to a Duration. Features Parses a variety of hu

null 5 Apr 25, 2023
replaces fixed-sized string prefixes & whole sections in binaries for fast, debuggable, reproducible builds

Replacing fixed-sized string prefixes in binaries to refix them to their build context Here's the long story about what refix does and why you'd want

Yossi Kreinin 30 Jul 16, 2024
Rust Imaging Library: A high-level Rust imaging crate.

ril Rust Imaging Library: A performant and high-level Rust imaging crate. Documentation • Crates.io • Discord What's this? This is a Rust crate design

Jay3332 18 Jan 5, 2023