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

查看:36
本文介绍了为什么在密码学中使用 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

现在您的原始字符串已被编码,第二个字符串成为您的密钥如果你用你的编码字符串异或你的密钥,你会得到你的原始字符串.

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 允许您轻松加密和解密字符串,其他逻辑操作则不然.

XOR allows you to easily encrypt and decrypt a string, the other logic operations don't.

如果你有更长的字符串,你可以重复你的键直到它足够长例如,如果您的字符串是 1010010011 那么您只需将密钥写入两次,它就会变成 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 密码的 维基百科链接.

Here's a wikipedia link on the XOR cipher.

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

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