C++: How to encrypt strings at compile time?

前端 未结 10 1284
北荒
北荒 2020-12-18 21:40

I want to hide some strings in my .exe so people can\'t simply just open the .exe and look at all the strings there. I don\'t care about the strength of the encrypting metho

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-18 22:28

    About the only way to do exactly what you suggest is to write a truly horrible macro. But here are some alternatives.

    1. Store the encrypted strings in a data file.
    2. Collect the strings in a single source file, then in the build, before actually compiling, go over it with a tool that will encrypt them (e.g. sed). You can automate this step.
    3. Use a powerful editor so that you can encrypt/decrypt the strings effortlessly, while you work.

提交回复
热议问题