Compile-time string obfuscation. More...
#include <obfuscatedstring.h>
Public Member Functions | |
| consteval | ObfuscatedString (const char(&str)[N]) |
| Encodes a string literal at compile time. | |
| String | decode () const |
| Decodes the obfuscated data back to the original string. | |
| operator String () const | |
| Implicit conversion to String via decode(). | |
Compile-time string obfuscation.
Strings wrapped with the PROMEKI_OBFUSCATE macro are encoded at compile time so the plaintext never appears in the binary. Each call site gets a unique key derived from the file name, line number, and build timestamp.
The encoding applies four operations per byte (XOR, modular add, bit-rotate, XOR) with 64-bit cipher-block-chaining so each output byte depends on the full history of all previous bytes. The per-byte key stream is derived from a splitmix64 finalizer, and the 64-bit CBC state is advanced with a multiply-xorshift step after each byte.
Usage:
| N | Size of the string literal (including the null terminator). |
| Seed | Unique per-site seed derived from file, line, and build time. |
|
inline |
Encodes a string literal at compile time.
The constructor is consteval, guaranteeing that encoding happens entirely at compile time and the plaintext literal is never emitted into the binary.
| str | The string literal to obfuscate. |
Decodes the obfuscated data back to the original string.
|
inline |