Python 使用凯撒密码解密
我正在开发一个密码保护程序,我有一个用于加密的Caesar密码,它是:Python 使用凯撒密码解密,python,python-3.x,list,encryption,Python,Python 3.x,List,Encryption,我正在开发一个密码保护程序,我有一个用于加密的Caesar密码,它是: # The encryption key for the Caesar Cipher encryptionKey = 16 # Caesar Cipher Encryption def passwordEncrypt (unencryptedMessage, key): # We will start with an empty string as our encryptedMessage encryptedMes
# The encryption key for the Caesar Cipher
encryptionKey = 16
# Caesar Cipher Encryption
def passwordEncrypt (unencryptedMessage, key):
# We will start with an empty string as our encryptedMessage
encryptedMessage = ''
# For each symbol in the unencryptedMessage we will add an encrypted symbol
into the encryptedMessage
for symbol in unencryptedMessage:
if symbol.isalpha():
num = ord(symbol)
num += key
if symbol.isupper():
if num > ord('Z'):
num -= 26
elif num < ord('A'):
num += 26
elif symbol.islower():
if num > ord('z'):
num -= 26
elif num < ord('a'):
num += 26
encryptedMessage += chr(num)
else:
encryptedMessage += symbol
return encryptedMessage
if choice == '2': # Lookup a password
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
我给用户提供了一系列选择,选择2允许用户查找保存的密码,即:
# The encryption key for the Caesar Cipher
encryptionKey = 16
# Caesar Cipher Encryption
def passwordEncrypt (unencryptedMessage, key):
# We will start with an empty string as our encryptedMessage
encryptedMessage = ''
# For each symbol in the unencryptedMessage we will add an encrypted symbol
into the encryptedMessage
for symbol in unencryptedMessage:
if symbol.isalpha():
num = ord(symbol)
num += key
if symbol.isupper():
if num > ord('Z'):
num -= 26
elif num < ord('A'):
num += 26
elif symbol.islower():
if num > ord('z'):
num -= 26
elif num < ord('a'):
num += 26
encryptedMessage += chr(num)
else:
encryptedMessage += symbol
return encryptedMessage
if choice == '2': # Lookup a password
print("Which website do you want to lookup the password for?")
for keyvalue in passwords:
print(keyvalue[0])
passwordToLookup = input()
密码保护程序对密码进行加密,但我需要它仅使用passwordEncrypt()函数对密码进行解密 我的答案被删除了吗?我似乎在任何地方都找不到它,我几乎可以肯定我发布了它。要使用您的函数进行解密,只需传递
key
的负数,例如-16
我的答案被删除了吗?我似乎在任何地方都找不到它,我几乎可以肯定我发布了它。要使用您的函数进行解密,只需传递key
的负数,例如-16