Single-header C++ string obfuscator. Your string literals are XOR-encrypted at compile time and only decrypted into a short-lived stack buffer when used. The plaintext never appears in the binary, and neither does a visible encrypted blob — the encrypted data is baked into the code as uint64 immediates, not into .rdata, so strings shows nothing.
- Encryption happens fully at compile time (
constexpr). - No plaintext in the binary.
- No visible encrypted string in
.rdata(stored as instruction immediates). - Per-build random keys derived from
__TIME__/__DATE__(no fixed magic constants). - Header only, no dependencies.
- C++17 or newer
- MSVC / Clang / GCC
/O2(or-O2) recommended so the compiler keeps the data as immediates
Include the header and wrap any string literal in hxx(...):
#include "crypt.h"
#include <iostream>
#include <string>
int main() {
std::string url = hxx("https://example.com/api");
std::cout << hxx("hello world") << "\n";
std::cout << url << "\n";
}hxx("text")returns a decryptedchar*(valid until the end of the full expression).hxx_("text")returns the raw encryptedboxobject if you want to hold it yourself.
Because hxx(...) gives a temporary, copy it into a std::string if you need to keep it:
std::string secret = hxx("keep me");hx::enc()XORs each 8-byte chunk of the string with a key stream at compile time.- The encrypted chunks are stored in an automatic
uint64array, so the compiler emits them asmov rax, imm64inside the function — not as a data string. dec()XORs the chunks back at runtime through avolatilepointer (which stops the optimizer from precomputing the plaintext).
Same string, decompiled in IDA Pro.
Before — a normal string literal sits in the binary in plain sight ("Hello World!\n"):
After — through hxx(...): only encrypted uint64 constants and a key built at runtime from __TIME__ / __DATE__ over a 246-byte stream (% 0xF6). No plaintext, no .rdata string:
MIT


