密钥密码
"""
如密钥短语密码为: university -> universty
明文: abcdefghijklmnopqrstuvwxyz
密文:jklmopqwxzuniverstyabcdfgh
"""
构造映射字典
# 构造映射 asc ---> crypt
def dic(x):
list_x =[]
list_z = []
for i in x:
list_x.append(ord(i))
for i in range(97,123):
if i not in list_x:
list_x.append(i)
list_ = list_x[26-len(x)-1:]
cr = list_+list_x[:26-len(list_)]
for i in range(97,123):
list_z.append(i)
return dict(map(lambda x,y:[x,y],list_z,cr))
# 构造映射 crypt ---> asc
def dic_2(x):
list_x =[]
list_z = []
for i in x:
list_x.append(ord(i))
for i in range(97,123):
if i not in list_x:
list_x.append(i)
list_ =