C++: How to encrypt strings at compile time?(C++:如何在编译时加密字符串?)
问题描述
我想在我的 .exe 中隐藏一些字符串,这样人们就不能简单地打开 .exe 并查看那里的所有字符串.我不关心加密方法的强度,所以我可能会使用 XOR 等.
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 method, so I will probably use XOR etc.
如何在编译时执行此操作?这样我的字符串就不会存储在 .exe 中,但加密版本会.然后,我每次都会使用我的解密功能在屏幕上显示这些字符串.
How can I do this at compile time? That way my strings won't be stored in the .exe but the encrypted versions would. Then, I would just use my decrypting function every time to display those strings on screen.
推荐答案
您可以使用宏对其进行加密或编写自己的预处理器
you can encrypt it using macros or write your own preprocessor
#define CRYPT8(str) { CRYPT8_(str " ") }
#define CRYPT8_(str) (str)[0] + 1, (str)[1] + 2, (str)[2] + 3, (str)[3] + 4, (str)[4] + 5, (str)[5] + 6, (str)[6] + 7, (str)[7] + 8, ' '
// calling it
const char str[] = CRYPT8("ntdll");
这篇关于C++:如何在编译时加密字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++:如何在编译时加密字符串?


基础教程推荐
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09