在Python中使用字典恢复加密的单词
我正在尝试使用 Python 中的前向搜索字典攻击来恢复 RSA 加密的 5 个字符单词,但遇到困难。该单词被加密成2个24位块(3648141 5604637),用空格填充最后一个块
e = 5
n = 21508387
table = {}
for ptext in range(65,90):
ctext = pow(ptext,e,n)
table[ctext] = ptext
print table
我知道我需要执行上述操作,以便它解密所有组合3个字符长AAA AAB ... ZZA ZZB等,但我只有什么解密单个字符 AB C.. XYZ 那么我如何让它一次解密 3 个字符?
我得到的打印输出是很多行,其中包含类似 {8521919L: 65} {7688462L: 66, 8521919L: 65} 但我在结果中看不到我的块,并且我假设带有冒号的数字是 ASCII?
我可以得到一些帮助吗?有什么建议吗? 谢谢
I'm trying to recover an RSA encrypted 5 character word using a forward search dictionary attack in Python but having difficulty. The word was encrypted in 2 24 bit blocks (3648141 5604637) padding last block with a space
e = 5
n = 21508387
table = {}
for ptext in range(65,90):
ctext = pow(ptext,e,n)
table[ctext] = ptext
print table
I know I need to do the above so that it decrypts all combinations 3 characters long AAA AAB... ZZA ZZB, etc but what I have only decrypts single characters A B C.. X Y Z so how do I get it to decrypt 3 chars at a time?
The print out I get is lots of lines that feature things like {8521919L: 65} {7688462L: 66, 8521919L: 65}
but I can't see my blocks in the results and I assume that the number have the colon is the ASCII?
Can I please get some help with this, any advice?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
生成所有三个字母的组合,将它们编码为整数,应用 pow 函数,报告它们何时与您的加密消息匹配。
迭代所有三个字母组合的最明显的方法是使用三个嵌套循环,而不是现在的循环。
Generate all three-letter combinations, encode them as integer, apply the pow function, report when they match your encrypted message.
The most obvious way to iterate through all three letter combinations is with three nested loops instead of the one you have right now.