# write by 2021/7/23
# QWE密码
DIC_QWE = "qwertyuiopasdfghjklzxcvbnm"
DIC_ABC = "abcdefghijklmnopqrstuvwxyz"
def encrypt_qwe(string):
ciphertext = ""
string = string.replace(" ", "")
for i in string:
if i in string:
if i in DIC_ABC:
ciphertext += DIC_QWE[DIC_ABC.index(i)]
else:
return -1
return ciphertext
def decrypt_qwe(string):
plaintext = ""
string = string.replace(" ", "")
for i in string:
if i in string:
if i in DIC_QWE:
plaintext += DIC_ABC[DIC_QWE.index(i)]
else:
return -1
return plaintext
if __name__ == '__main__':
ciphertext_ = encrypt_qwe("i love you")
plaintext_ = decrypt_qwe(ciphertext_)
print(f"{plaintext_}: {ciphertext_}")