为什么在加密中使用XOR? [英] Why is XOR used in cryptography?

查看:140
本文介绍了为什么在加密中使用XOR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在加密算法中仅使用XOR,而未使用其他逻辑门,例如OR,AND和NOR?

Why is only XOR used in cryptographic algorithms, and other logic gates like OR, AND, and NOR are not used?

推荐答案

逻辑运算XOR是所有加密中唯一使用的逻辑运算,并不是完全正确的说法,但是它是唯一专门用于加密的两种方式。

It isn't exactly true to say that the logical operation XOR is the only one used throughout all cryptography, however it is the only two way encryption where it is used exclusively.

解释如下:

想象一下,您有一串二进制数字 10101
和您将字符串 10111 与它进行异或,得到 00010

Imagine you have a string of binary digits 10101 and you XOR the string 10111 with it you get 00010

现在您的原始字符串已编码,如果您将密钥与编码的字符串进行XOR运算,则第二个字符串将成为您的密钥

now your original string is encoded and the second string becomes your key if you XOR your key with your encoded string you get your original string back.

XOR

如果您有一个更长的字符串,您可以重复您的密钥直到足够长的$ b为止。例如,如果您的字符串为 1010010011 ,则$ b可以简单地写成命令您的密钥两次,它将变成 1011110111 并与新字符串进行异或

If you have a longer string you can repeat your key until its long enough for example if your string was 1010010011 then you'd simple write your key twice and it would become 1011110111 and XOR it with the new string

这里是 XOR密码上的Wikipedia链接。

这篇关于为什么在加密中使用XOR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆