简单替换密码编程与破解
1. translateMessage() 函数
translateMessage() 函数用于加密和解密。以下是其代码实现:
def translateMessage(key, message, mode):
translated = ''
charsA = LETTERS
charsB = key
if mode == 'decrypt':
# For decrypting, we can use the same code as encrypting. We
# just need to swap where the key and LETTERS strings are used.
charsA, charsB = charsB, charsA
# Loop through each symbol in the message:
for symbol in message:
if symbol.upper() in charsA:
# Encrypt/decrypt the symbol:
symIndex = charsA.find(symbol.upper())
if symbol.isupper():
translated += charsB[symIndex].upper()
else:
简单替换密码编程与破解方法
超级会员免费看
订阅专栏 解锁全文
2231

被折叠的 条评论
为什么被折叠?



