简单移位替代加密,密钥一共有26种可能(0,...,25),循环解密,看解密后的明文就可以猜中密钥是多少。

python程序如下:

alphabet_table = 'abcdefghijklmnopqrstuvwxyz'
ciphertext  = 'irxuvfruhdqgvhyhqbhduvdir'
plaintext   = 'fourscoreandsevenyearsago'
ciphertext1 = 'csyevixivqmrexih'

#decrypt
for i in range(0,26):
    result =''
    for j in range(0,len(ciphertext1)):
        index = ord(ciphertext1[j]) - ord('a')
        index = (index - i) % len(alphabet_table)
        result += alphabet_table[index]
    print result

相关文章:

  • 2022-12-23
  • 2021-12-31
  • 2021-11-15
  • 2022-12-23
  • 2021-12-05
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2022-02-02
  • 2021-07-01
  • 2021-10-08
相关资源
相似解决方案