memfrob() 函数原型如下:
[C++] 纯文本查看 复制代码 #include <string.h>
void *memfrob(void *s, size_t n);
该函数将 s 指向的内存空间的前 n 个字符逐一与 42 做 XOR 运算,用途是可以隐藏一个特定字符串的内容,如果需要还原,那么就再对 42 做一次 XOR 运算即可。该函数为 GNU C 所独有。
测试代码:
[C++] 纯文本查看 复制代码 #include <stdio.h>
#include <string.h>
int main()
{
char my[] = "This is my secret^_^";
printf ("you can see it: %s\n", my);
memfrob(my, strlen(my));
printf ("is it my secret? : %s\n", my);
printf ("restore it.......\n");
memfrob(my, strlen(my));
printf ("you can see it again: %s\n", my);
return 0;
}
运行输出:./memfrob
you can see it: This is my secret^_^
is it my secret? : ~BCY
CY
GS
YOIXO^tut
restore it.......
you can see it again: This is my secret^_^ |