String and Number Obfuscation
==============================
> Forked from [obfstr](https://github.com/CasualX/obfstr) by CasualX — adds `obfnum!` macro for numeric constant obfuscation.
[](https://opensource.org/licenses/MIT)
[](https://crates.io/crates/obfany)
[](https://docs.rs/obfany)
[](https://github.com/jeanzuck/obfany/actions)
Compiletime string and number constant obfuscation for Rust.
The string constant itself is embedded in obfuscated form and deobfuscated locally.
This reference to a temporary value must be used in the same statement it was generated.
See the documentation for more advanced use cases.
Examples
--------
The `obfstr!` macro returns the deobfuscated string as a temporary value:
```rust
use obfany::obfstr as s;
assert_eq!(s!("Hello 🌍"), "Hello 🌍");
```
The `wide!` macro provides compiletime utf16 string constants:
```rust
let expected = &['W' as u16, 'i' as u16, 'd' as u16, 'e' as u16, 0];
assert_eq!(obfany::wide!("Wide\0"), expected);
```
The `random!` macro provides compiletime random values:
```rust
const RND: i32 = obfany::random!(u8) as i32;
assert!(RND >= 0 && RND <= 255);
```
Compiletime random values are based on `file!()`, `line!()`, `column!()` and a fixed seed to ensure reproducibility.
This fixed seed is stored as text in the environment variable `OBFANY_SEED` and can be changed as desired.
The `obfnum!` macro obfuscates numeric constants:
```rust
let secret: u32 = obfany::obfnum!(0x1234_u32);
assert_eq!(secret, 0x1234_u32);
```
Always use a typed literal suffix (e.g. `0x1234_u32`, `-9999_i64`, `3.14_f32`) to ensure correctness.
Supports all primitive numeric types: `u8`, `u16`, `u32`, `u64`, `u128`, `i8`, `i16`, `i32`, `i64`, `i128`, `usize`, `isize`, `f32`, `f64`.
The value is stored XOR-encrypted in the binary and decrypted at runtime.
Credits
-------
This project is a fork of [obfstr](https://github.com/CasualX/obfstr)
by [CasualX](https://github.com/CasualX), licensed under MIT.
Changes from upstream:
- Renamed crate to `obfany`
- Added `obfnum!` macro for compiletime numeric constant obfuscation
License
-------
Licensed under [MIT License](https://opensource.org/licenses/MIT), see [license.txt](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.