# cpp-obfuscator **Repository Path**: beebeeyoung/cpp-obfuscator ## Basic Information - **Project Name**: cpp-obfuscator - **Description**: No description available - **Primary Language**: C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-29 - **Last Updated**: 2025-08-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # cpp-obfuscator [![License](https://img.shields.io/badge/Licence-MIT-blue.svg)](https://github.com/revsic/cpp-obfuscator/blob/master/LICENSE) [![Build Status](https://dev.azure.com/revsic99/cpp-obfuscator/_apis/build/status/revsic.cpp-obfuscator?branchName=master)](https://dev.azure.com/revsic99/cpp-obfuscator/_build/latest?definitionId=3&branchName=master) C++ implementation of compile time obfuscator ## Compiler Support | Compiler | Version | | -- | -- | | Visual Studio | 2019 | | Clang++ | 8.0 | | g++ | 7.3 | | Apple Clang | Mojave | ## Usage Use existing single header [obfuscator.hpp](./obfuscator.hpp) or run [script](./script/merge.py) to merge multiple headers in directory [obfuscator](./obfuscator). ```bash python -m script.merge ``` Include [obfuscator.hpp](./obfuscator.hpp) to use it. ```C++ #include "../obfuscator.hpp" template constexpr char xor_(char c) { return c ^ key; } std::cout << obfs::make_string, xor_<0x50>>("Hello World !\n").decode(); ``` ## String Compile time string obfuscator. No more raw string in binary, sample [string_obfuscator](./sample/string_obfs.cpp). 0. Sample encoder, decoder ```C++ template constexpr char xor_(char c) { return c ^ key; } template constexpr char add(char c) { return c + Key; } template constexpr char comp(char c) { return f(g(c)); } ``` 1. Single encoder, decoder. ```C++ std::cout << obfs::make_string, xor_<0x50>>("Hello World !\n").decode(); ``` 2. Multiple encoder, decoder and random selection. ```C++ using table = obfs::make_table< obfs::encoder_seq, add<10>, comp, add<10>>>, obfs::decoder_seq, add<-10>, comp, xor_<0x50>>>>; std::cout << obfs::make_string("Hello World !\n").decode(); ``` 3. Multiple encoder, decoder as pair. ```C++ using table = obfs::make_pair_table< obfs::encoder_pair, xor_<0x50>>, obfs::encoder_pair, add<-10>>, obfs::encoder_pair, add<10>>, comp, xor_<0x50>>> >; std::cout << obfs::make_string
("Hello World !\n").decode(); ``` 4. String obfuscator macro. ```C++ MAKE_STRING(str, "Hello World !\n", table); std::cout << str.decode(); ``` ## Finite state machine Compile time finite state machine based routine obfuscator, sample [state_machine](./sample/state_machine.cpp). 0. Make state table. ```C++ using namespace obfs; using machine = StateMachine< Stage, Next>, Stage>, Stage>, Stage, Next>, Stage>>; ``` 1. Run state machine, each execution returns next state. ```C++ auto next1 = machine::run(state1{}, event5{}); // dummy1 executed auto next2 = machine::run(next1, event2{}); auto next3 = machine::run(next2, event3{}); // dummy2 executed auto next4 = machine::run(next3, Trigger{}); // action executed ```