C 异或
#include <stdio.h>
#define key 0x86
int main(int argc, char *argv[])
{
char text[100];
int i,j;
for(i=0;i<100;i++){
text[i]=getchar();
if(text[i]=='\n'){
text[i]='\0';
break;
}
}
for(j=0;j<i;j++){
text[j]=text[j] ^ key;
}
puts(text);
for(j=0;j<i;j++){
text[j]=text[j] ^ key;
}
puts(text);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define KEY 0x86
int main()
{
char p_data[16] = {"Hello World!"};
char Encrypt[16]={0},Decode[16]={0};
int i;
for(i = 0; i < strlen(p_data); i++)
{
Encrypt[i] = p_data[i] ^ KEY;
}
for(i = 0; i < strlen(Encrypt); i++)
{
Decode[i] = Encrypt[i] ^ KEY;
}
printf("Initial date: %s\n",p_data);
printf("Encrypt date: %s\n",Encrypt);
printf("Decode date: %s\n",Decode);
return 0;
}
https://blog.csdn.net/wwt18811707971/article/details/78291490
https://www.cnblogs.com/zhidongjian/p/10097790.html
https://blog.csdn.net/tonkeytong/article/details/52451509
https://blog.csdn.net/tonkeytong/article/details/52451509
C语言位运算符:与、或、异或、取反、左移和右移