Skip to content
/ obfstr Public
forked from CasualX/obfstr

Compiletime string literal obfuscation for Rust

License

Notifications You must be signed in to change notification settings

GWSoT/obfstr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

String Obfuscation

MIT License crates.io docs.rs Build Status

Compiletime string literal obfuscation for Rust.

Examples

Comes with a simple wide! macro to provide compile time utf16 string literals:

let expected = &['W' as u16, 'i' as u16, 'd' as u16, 'e' as u16];
assert_eq!(obfstr::wide!("Wide"), expected);

The obfstr! macro returns a borrowed temporary and may not escape the statement it was used in:

assert_eq!(obfstr::obfstr!("Hello 🌍"), "Hello 🌍");

The obflocal! macro returns the ObfBuffer with the decrypted string and is more flexible but less ergonomic:

let str_buf = obfstr::obflocal!("Hello 🌍");
assert_eq!(str_buf.as_str(), "Hello 🌍");

The obfconst! macro returns the encrypted ObfString for use in constant expressions:

static GSTR: obfstr::ObfString<[u8; 10]> = obfstr::obfconst!("Hello 🌍");
assert_eq!(GSTR.decrypt(0).as_str(), "Hello 🌍");

We're already depending on rand, why not throw in a compiletime random number generator:

const RND: i32 = obfstr::random!(u8) as i32;
assert!(RND >= 0 && RND <= 255);

License

Licensed under MIT License, see license.txt.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.

About

Compiletime string literal obfuscation for Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%