while True:
password_way = input('您要翻译密码还是加密密码(翻译/加密):')
new_password = []
a, b, c, d, e, f = 0, 0, 0, 0, 0, 0
if password_way == '加密':
encryption = input('请输入您要加密的密码(六位数字):')
old_password = list(map(int, encryption))
print('加密前的密码是:', old_password)
for i in range(len(old_password)):
a = old_password[3]
b = old_password[5]
c = old_password[0] * old_password[5]
d = old_password[2]
e = old_password[1] * old_password[5]
f = old_password[4]
new_password = [a, b, c, d, e, f]
print('加密后的密码是:', new_password)
elif password_way == '翻译':
translate = input('请输入加密后的密码,每一位用英文逗号隔开:')
a, b, c, d, e, f = map(int, translate.split(','))
new_password = [a, b, c, d, e, f]
g = int(new_password[2] / new_password[1])
h = int(new_password[4] / new_password[1])
i = new_password[3]
j = new_password[0]
k = new_password[5]
l = new_password[1]
old_password = [g, h, i, j, k, l]
print('原始的密码是:', end='')
for i in old_password:
print(i, end='')
break
else:
print('输入错误,请重新输入!')
|