This is a header-only library to compile-time string obfuscation works above c++20
This is more efficient for humans.
This library is primarily effective when a human performs manual static analysis.
It is ineffective when analyzed by AI or similar technologies.
Additionally, since the specification requires embedding keys in the binary,
it is not suitable for sensitive information such as tokens or API keys.
#include <iostream>
#include "CryptStr.h"
int main()
{
// easy to use, just like a normal string literal
std::string protected_hello = protect("Hello, World");
// Also works with wide strings and UTF-8 strings or any other character type
std::wstring protected_wide_hello = protect(L"Hello, World");
std::u8string protected_u8_hello = protect(u8"Hello, World");
//
// Also there is a lite weighted version of the protection, which is faster and smaller, but less secure
std::string lite_protected_hello = lprotect("Hello, World");
//
//Output: Hello, World
std::cout << protected_hello << std::endl;
std::cout << lite_protected_hello << std::endl;
std::wcout << protected_wide_hello << std::endl;
std::cout << reinterpret_cast<const char*>(protected_u8_hello.c_str()) << std::endl;
}(Also you can check CryptStr.cpp)
See CryptStr.h
At compile time, a seed is determined based on __COUNTER__ and __TIME__, and the string is obfuscated using XOR.
Even for the same string, each instance will have a different seed, making it less readable from an analyst’s perspective.
Encrypted string and plain string
String after encrypted
This is a function that decrypts the strings using seed functions different each character
Since Light reuses the seed function for each string, its memory usage is about X% less than Normal's.
Normal treats the seed function as a separate one for each character, so its memory usage increases.