Are there programs available that can obfuscate C++ code, so it becomes very hard to read, but at the same time, the behavior of the compiled binary doesn't change, and there is none or negligible performance loss.

Note: There is already a question asked at StackOverflow - https://stackoverflow.com/questions/1025494/obfuscating-c-c-code. But it's closed as off-topic there.


2 Answers 2


Basically you can use global replaces to:

  1. Remove all comments
  2. Remove all blank lines
  3. Remove 3/4 of other line feeds
  4. Replace all function names, (except main), with Fnnnn where nnnn is a 4 digit number
  5. Take random chunks of code and move them into macro definitions
  6. Replace all variable names with Vnnnnnn where nnnnnn is a 6 digit number
  7. Rename all Classes Cnnnn
  8. Rename all defines with Dnnnnn
  9. Rename all the files Fnnnn

That will give you a fair degree of obfuscation, (just like the code written by some of the people that I have worked with - maybe you should just hire some of them).

Depending on your tool chain you could also compile your code to ASM output with full optimisation turned on and then reverse engineer portions of your code to the way that the optimiser does it.

  • 1
    And having manually done all this once, you now modify your original source code.
    – Ira Baxter
    Aug 19, 2014 at 7:55
  • You can easily have a set of either editor macros, or better yet python scripts, to do this for you! Aug 19, 2014 at 10:31
  • Changing the formatting is pointless, as there are tools which can put it into proper formatting and indentation. Stripping the function and variable names, and removing the comments does make sense, though.
    – sashoalm
    Oct 19, 2014 at 8:43

Posting the only relevant answer from the StackOverflow question:

Mangle-It C++ Code Obfuscator is paid software, licenses are for $69.99.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.