异或 (XOR) 加密的安全性
已知 XOR 加密非常弱。但是,如果我有一个由多个不同(理想情况下是质数)长度的密钥组成的密钥,这些密钥组合起来形成一个更长的密钥,那么它有多弱。例如,我有一个长度为 5、9 和 11 的文本密钥。如果我仅使用 XOR 加密应用第一个密钥,那么它应该很容易破解,因为加密字节将每 5 个字节重复一次。然而,如果我“覆盖”其中的 3 个键,我会得到 5*9*11 = 495 的有效非重复长度。这对我来说听起来相当强大。如果我使用一首诗的几节并使用每一行作为键,那么我的非重复长度将比大多数文件大得多。这会有多强(假设密钥保密! :)
)
XOR encryption is known to be quite weak. But how weak is it if I have a key that is made up of multiple keys of different (ideally prime) lengths which are combined to make a longer key. eg I have a text keys of length 5, 9 and 11. If I just apply the first key using XOR encryption then it should be easy to break as the encryption byte will repeat every 5 bytes. However if I 'overlay' the 3 of these keys I get an effective non-repeating length of 5*9*11 = 495. This sounds to me pretty strong. If I use a couple of verses of a poem using each line as a key then my non-repeating length will be way bigger than most files. How strong would this be (providing the key remains secret! :)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
XOR 加密的强度与密钥流一样强。如果您使用“一次性密码本”(一系列物理生成的随机数,您只使用一次)进行异或,那么理论上您的加密是牢不可破的。然而,您确实存在隐藏和分发密钥的问题。
所以你的问题归结为 - “由三个文本字符串组成的密钥流的安全性/随机性如何?”答案是“一点也不安全”。可能足以将你的妹妹拒之门外,但如果你有一个像我一样聪明的妹妹,那就不一定了。
XOR encryption is exactly as strong as the key stream. If you XOR with a "One time pad" - a sequence of physically generated random numbers that you only use once, then your encryption is theoretically unbreakable. You do have the problem however of hiding and distributing the key.
So your question comes down to - "how secure/random is a keystream made of three text strings?" The answer is "not very secure at all". Probably good enough to keep out your little sister, but not necessarily if you've got a smart little sister like I have.
那么“已知明文”攻击呢?如果您知道同一字符串的加密版本和明文版本,则可以检索密钥。
http://en.wikipedia.org/wiki/XOR_cipher
http://en.wikipedia.org/wiki/Known-plaintext_attack
http://en.wikipedia.org/wiki/Stream_cipher_attack
What about the 'known plaintext' attack? If you know the encrypted and the cleartext versions of the same string, you can retrieve the key.
http://en.wikipedia.org/wiki/XOR_cipher
http://en.wikipedia.org/wiki/Known-plaintext_attack
http://en.wikipedia.org/wiki/Stream_cipher_attack
如果 P 和 Q 是两种独立的加密方法,则复合加密函数 P(Q(x)) 不会弱于 P(x) 或 Q(x) 中较强的一个,但不一定会明显更强任何一个。为了使复合密码功能获得一定的强度,包含它的操作必须满足某些标准。任意组合弱密码,无论使用多少,都不太可能产生强密码。
If P and Q are two independent cryptographic methods, the composite cryptographic function P(Q(x)) won't be any weaker than the stronger of P(x) or Q(x), but it won't necessarily be meaningfully stronger either. In order for a composite cryptographic function to gain any strength, the operations comprising it have to meet certain criteria. Combining weak ciphers arbitrarily, no matter how many one uses, is unlikely to yield a strong cipher.