题目: This time I am using a digraph crypto scheme to encrypt one letter into two characters. With only 26 different letters I am able to encrypt up to 26*26 different characters. The big problem again is sharing the key, but the cipher is easily broken anyway. The message is in the current language, is written with correct case and punctuation. There are no line breaks.

Good luck!

密文:cqzvftzijojqsweczyjqswtuzvftirqc wszvec hwivrajotdbsswivhw swcptuir loivirirjqziiv irecraraivirirmheczyzytdqc gyjqir ftzvsw swzvzv hwtumhmhturaeczysw ivtuswcpivjouc kujqir tuswxr gyivzyzyuc zizvzvhw ytzvezqc bpftswivjo swcptuir deivtdkuzvjohw jqir irzvzyecswtuzvftaw tuftmhmhftftjojqezezziftqc

#c = 'cqzvftzijojqsweczyjqswtuzvftirqc wszvec hwivrajotdbsswivhw swcptuir loivirirjqziiv irecraraivirirmheczyzytdqc gyjqir ftzvsw swzvzv hwtumhmhturaeczysw ivtuswcpivjouc kujqir tuswxr gyivzyzyuc zizvzvhw ytzvezqc bpftswivjo swcptuir deivtdkuzvjohw jqir irzvzyecswtuzvftaw tuftmhmhftftjojqezezziftqc'
c  = "aodrpqucxxrhawzpkyrhawyadrpqrtnf tadrzp zajginxxoigiawjgza awzeyart dpjgrtrtrhucjg rtzpininjgrtrtmkzpkykyoinf zhrhrt pqdraw awdrdr zayamkmkyainzpkyaw jgyaawzejgxxwe cgrhrt yaawfq zhjgkykywe ucdrdrza cfdrlpnf xkpqawjgxx awzeyart dejgoicgdrxxza rhrt rtdrkyzpawyadrpqrj ucrhmkmkdrmkdrucdpyazertnf"
 
dic = {}

def get_c_double_chars():
    c_dic = []
    i = 0
    while i < len(c):
        if c[i] == ' ':
            i += 1         #jump the space
            continue
        if c_dic.count(c[i:i+2]) == 0:
            c_dic.append(c[i:i+2])
        i += 2
    #dic = {c_dic[i]:chr(ord('a')+i) for i in range(len(c_dic))}
    dic.update({c_dic[i]:'?' for i in range(len(c_dic))})
    #print(c_dic)
    print(dic)


get_c_double_chars()

def guess_dic(c_word,m_word):   #密文单词 c_word,  猜测的明文单词m_word
    for i in range(len(m_word)):
        j = i * 2
        dic[c_word[j:j+2]] = m_word[i]
    print(dic)

def transf_c():
    m = ''
    i = 0
    while i < len(c):
        if c[i] == ' ':
            m += ' '
            i += 1
            continue
        m += dic[c[i:i+2]]
        i += 2
    print(c)
    print(m)

'''    
#猜测,第一个单词'cqzvftzijojqsweczyjqswtuzvftirqc'是 'congratulations!'
结果:congratulations! ?ou ???r??t?? t?is ??ssag? su???ss?ull?! ?as not too ?i??i?ult ?it??r? ?as it? ??ll? goo? ?o?! ?nt?r t?is ????or? as solution? ga??o?og?i?s!
然后猜测其它单词

guess_list = [ ['cqzvftzijojqsweczyjqswtuzvftirqc','congratulations!'],
               ['irzvzyecswtuzvftaw','solution'],
               ['wszvec','you'],
               ['irecraraivirirmheczyzytdqc','successfull'],
               ['hwivrajotdbsswivhw','decrypted'],
               ['swcptuir','this'],
               ['loivirirjqziiv','message'],
               ['gyjqir','was'],
               ['ytzvezqc','job'],
              ]
'''
guess_list = [ ['aodrpqucxxrhawzpkyrhawyadrpqrtnf','congratulations!'],
             ]

for pair in guess_list:
     guess_dic(pair[0],pair[1])

transf_c()