JDr*_*159 5 c c++ bit-manipulation xor caret
在位上使用异或是我很清楚的事情.但在这里,XOR正致力于个性化角色.那么这是否意味着构成角色的字节正在被异或?这看起来像什么?
#include <iostream.h>
int main()
{
char string[11]="A nice cat";
char key[11]="ABCDEFGHIJ";
for(int x=0; x<10; x++)
{
string[x]=string[x]^key[x];
cout<<string[x];
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我知道XORed位看起来像这样:
1010
1100
0110
XOR具有很好的属性,如果您使用相同的数据对XOR进行两次异或,则可以获得原始属性.您发布的代码是一些基本的加密函数,它使用密钥"加密"字符串.得到的密文可以通过相同的程序进行解密.