libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
ObfuscatedString< N, Seed > Class Template Reference

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().
 

Detailed Description

template<size_t N, uint64_t Seed>
class ObfuscatedString< N, Seed >

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:

Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_OBFUSCATE(str)
Obfuscates a string literal at compile time.
Definition obfuscatedstring.h:163
const T & value(const Result< T > &r)
Returns the value from a Result.
Definition result.h:56
Template Parameters
NSize of the string literal (including the null terminator).
SeedUnique per-site seed derived from file, line, and build time.

Constructor & Destructor Documentation

◆ ObfuscatedString()

template<size_t N, uint64_t Seed>
consteval ObfuscatedString< N, Seed >::ObfuscatedString ( const char(&)  str[N])
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.

Parameters
strThe string literal to obfuscate.

Member Function Documentation

◆ decode()

template<size_t N, uint64_t Seed>
String ObfuscatedString< N, Seed >::decode ( ) const
inline

Decodes the obfuscated data back to the original string.

Returns
The decoded plaintext as a String.

◆ operator String()

template<size_t N, uint64_t Seed>
ObfuscatedString< N, Seed >::operator String ( ) const
inline

Implicit conversion to String via decode().

Returns
The decoded plaintext as a String.

The documentation for this class was generated from the following file: