题目59:使用暴力攻击,你能解开这个异或加密吗?
projecteuler吧
全部回复
仅看楼主
level 6

电脑上的每个字符都有一个唯一编码,通用的标准是ASCII (American Standard Code for Information Interchange 美国信息交换标准编码)。例如大写A = 65, 星号(*) = 42,小写k = 107。
一种现代加密方法是用一个密钥中的给定值,与一个文本文件中字符的ASCII值进行异或。使用异或方法的好处是对密文使用同样的加密密钥可以得到加密前的内容。例如,65 XOR 42 = 107, 然后 107 XOR 42 = 65。
对于不可攻破的加密,密钥的长度与明文信息的长度是一样的,而且密钥是由随机的字节组成的。用户将加密信息和加密密钥保存在不同地方,只有在两部分都得到的情况下,信息才能被解密。
不幸的是,这种方法对于大部分用户来说是不实用的。所以一种修改后的方案是使用一个密码作为密钥。如果密码比信息短,那么就将其不断循环直到明文的长度。平衡点在于密码要足够长来保证安全性,但是又要足够短使用户能够记得。
你的任务很简单,因为加密密钥是由三个小写字母组成的。文件 cipher1.txt (右键另存为)包含了加密后的ASCII码,并且已知明文是由常用英语单词组成。使用该文件来解密信息,然后算出明文中字符的ASCII码之和。
2012年05月10日 16点05分 1
level 6
cipher1.txt在:projecteuler点net/project/cipher1.txt
2012年05月10日 16点05分 2
level 10
(The Gospel of John, chapter 1) 1 In the beginning the Word already existed. He was with God, and he was God. 2 He was in the beginning with God. 3 He created everything there is. Nothing exists that he didn't make. 4 Life itself was in him, and this life gives light to everyone. 5 The light shines through the darkness, and the darkness can never extinguish it. 6 God sent John the Baptist 7 to tell everyone about the light so that everyone might believe because of his testimony. 8 John himself was not the light; he was only a witness to the light. 9 The one who is the true light, who gives light to everyone, was going to come into the world. 10 But although the world was made through him, the world didn't recognize him when he came. 11 Even in his own land and among his own people, he was not accepted. 12 But to all who believed him and accepted him, he gave the right to become children of God. 13 They are reborn! This is not a physical birth resulting from human passion or plan, this rebirth comes from God.14 So the Word became human and lived here on earth among us. He was full of unfailing love and faithfulness. And we have seen his glory, the glory of the only Son of the Father.
2012年05月11日 03点05分 3
level 10
key == god
2012年05月11日 03点05分 4
level 6
回复4楼:用aaa遍历到zzz还是用字典?
2012年05月11日 03点05分 5
level 10
肯定是遍历啊
先解密前 50 位
把遍历结果存入文件
从中搜索 the
然后就能找到了
2012年05月11日 03点05分 6
level 10
因为不知道 key 是否为有意义的单词
2012年05月11日 03点05分 7
level 6
这都行……[]
2012年05月11日 04点05分 8
level 10
呵呵,破解密码嘛,什么办法都要想的
2012年05月11日 04点05分 9
1