1.自己写个秘钥,这种方式只有知道程序中的秘钥才能破解
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
//加密解密程序
void encrypt(char *message, const char *key)
{
int i;
int len = strlen(key);
while(*message) {
//对message的每一个字符和key进行按位异或
for(i = 0; i < len; i++) {
*message = *message ^ (int)key[i];
}
message++;
}
}
int main()
{
char s[] = "test IOT";
//密匙
char *key = "IOT@163.com";
//运行一次:进行加密
encrypt(s, key);
printf("加密:%s\n", s);
//再运行:进行解密
encrypt(s, key);
printf("解密:%s\n", s);
return 0;
}