https://github.com/x86byte/sbox
Compile-time AES string obfuscation for C++
https://github.com/x86byte/sbox
advanced-encryption-standard aes aes-128 aes-decryption aes-encryption compile-time-obfuscation encryption-decryption obfuscate-strings obfuscation reverse-engineering runtime-encryption string-encoding string-encrypt string-encryption string-encryption-high-resiliency
Last synced: 3 days ago
JSON representation
Compile-time AES string obfuscation for C++
- Host: GitHub
- URL: https://github.com/x86byte/sbox
- Owner: x86byte
- License: mit
- Created: 2026-05-25T07:49:51.000Z (23 days ago)
- Default Branch: main
- Last Pushed: 2026-05-26T11:42:57.000Z (22 days ago)
- Last Synced: 2026-06-14T14:03:52.303Z (3 days ago)
- Topics: advanced-encryption-standard, aes, aes-128, aes-decryption, aes-encryption, compile-time-obfuscation, encryption-decryption, obfuscate-strings, obfuscation, reverse-engineering, runtime-encryption, string-encoding, string-encrypt, string-encryption, string-encryption-high-resiliency
- Language: C++
- Homepage:
- Size: 44.9 KB
- Stars: 97
- Watchers: 2
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sbox - Compile-time AES string obfuscation for C++
Standard solutions rely on `length + "#" + string`. That is trivial to reverse.
**sbox** utilizes a `constexpr` AES-128 block cipher to mutate strings into high-entropy noise.
### The Story
During the Neetcode "Encode and Decode Strings" challenge, I ported the AES engine from my obfuscation project, **[Obfusk8](https://github.com/x86byte/Obfusk8)**.
The implementation passed in **7ms** on the first submission. Cryptographic security shouldn't be a trade-off for performance.
### Features
- **No Delimiters:** Fixed-width headers and block mutation replace predictable separators.
- **Binary Safe:** Effortlessly handles raw payloads and null bytes.
- **Static Stealth:** Plaintext is eliminated at compile-time. Using the provided macros, `strings.exe` (or `strings` in linux) returns zero results.
### How to Use
Check the [EXAMPLES](https://github.com/x86byte/sbox/tree/main/EXAMPLES) folder for implementation details:
1. **Multi-String Example (`sbox_test.cpp`):**
Demonstrates how to handle a `vector` using the `_OBF(str)` macro for batch processing. Useful for transit-ready obfuscation.
2. **Single String Example (`sbox_test1.cpp`):**
Demonstrates atomic materialization using the `ObfStr(str)` macro. Best for single variable assignments:
```cpp
string s = ObfStr("ama obfuscation addicted");
```
### Performance
**7ms runtime.**
Proving that overkill can still be optimal.
---
**Author:** [x86byte](https://github.com/x86byte)