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語言位運算符:與、或、異或、取反、左移和右移

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容