原文题目:
Oh dear, I guess you have cracked the two caesar cryptos...
This one is more difficult. Although a simple substitution is easily cracked...
Again the characters are limited to A-Z... But I think I can come up with a 256 version again.
Enjoy!
根据替换加密的内容,可以得知所有的字母都用其他的字母进行对应,获得最终的结果,因此,字母频率不发生改变,最先想到的方法是对字母频率进行统计,从而对其中的数据进行猜测解密,这里的替换仅包含A-Z,从而进行接下来的猜测。
密文信息为:
WP RSL MFIXYSRP YBQ PBH JMA OLMQ RSXT IP COXLAQ X MI XINOLEELQ GLOP KLFF QBAL PBHO TBFHRXBA ZLP XT AQLMSXCNLAQA RSXT FXRRFL JSMFFLAYL KMT ABR RBB SMOQ KMT XR
首先,对字母出现频率进行统计:
def substitution():
text = input()
all = []
for i in range(26):
all.append(0)
for i in text:
if(i == ' '):
continue
else:
all[ord(i) - ord('A')] += 1
print(all)
return
可以得到结果:
[9, 9, 2, 0, 2, 8, 1, 3, 4, 2, 3, 14, 9, 2, 6, 7, 8, 10, 7, 6, 0, 0, 1, 11, 3, 1]
可以发现出现最多的字母为L,共出现14次,因此,根据字母频率表猜测L为e 。
接着发现单独出现的字母是X,因为X可能是e或者是i,再加上XR处在结尾,因此猜测为it,XT为句中,猜测为is,进一步RSXT表示t-is,因此S表示h,根据这些方法进行推测,最终获得明文为:
by the almighty god you can read this my friend I am impressed very well done your solution key is ndeahifpendn this little challenge was not too hard was it
因此,结果是ndeahifpendn