攻防世界-密码学-Decrypt-the-Message

1. 题目信息

题目要求我们解密附件中的信息;打开附件,里面是一首诗,最后给出需要解密的信息。

2. 分析

此题考察Poem加密;举例说明加密过程。
诗:for my purpose holds to sail beyond the sunset, and the baths of all the western stars until I die.
明文:We have run out of cigars, situation desperate.
从诗中选择5个词for,sail,all,stars,die,将这些词中的每个字母排序(相同的不合并),即

f o r s a i l a l
6 12 13 15 1 7 9 2 10
l s t a r s d i e
11 16 18 3 14 17 4 8 5

上表共有18个字母,将明文以18个字母一组分成若干行,最后一行未满之处用a,b,...进行填充,即

1 2 3 4 5 6 7 8 9
w e h a v e r u n
r s s i t u a t i
t e a b c d e f g
10 11 12 13 14 15 16 17 18
o u t o f c i g a
o n d e s p e r a
h i j k l m n o p

再根据第一个表将各列置换,即eud tdj ...,最后连接起来生成密文。

破解的思路就是从诗中穷举各种取词情况,然后进行解密,然后选择可读的“明文”,已有人写好破解的工具

3.解题

将诗与密文分别存为poem.txt,cip.txt并移到与poemcode.py同目录下,使用工具破解:

$ python poemcode.py poem.txt cip.txt
...
ifytuothikcrnyptorapyisheansnweroyoturprbletheyoulodnotnowkwhatourrobemiuasbcdfgheijklnoprst
ifyouthinkcryptographyistheanswertoyourproblemthenyoudonotknowwhatyourproblemisabcdefghijklmnopqrstu
pakprictiyorhftyselorohyphurbeewterunhwooaywtooonrbpofjhsgkeilncmbrt
...

中间的为明文。

原文地址:https://www.cnblogs.com/coming1890/p/13520417.html