Skip to content

Latest commit

 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About this

This is a header-only library to compile-time string obfuscation works above c++20

Disclaimer

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.

Usage

#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)

Download

See CryptStr.h

How it works

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.

Analysis results

Encrypted string and plain string

image

String after encrypted

image

This is a function that decrypts the strings using seed functions different each character

image

Difference of protection between Normal and Light

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.

About

a library for crypt strings at compile-time

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages