【发布时间】:2021-05-16 20:40:16
【问题描述】:
所以我使用 pycryptodome 使用带有 AES 的密钥加密消息。然后,作为测试,我想使用具有相同密钥的 AES 解密加密消息。我在这里做了,但是解密消息的结果与加密消息的结果不一样。也许我误解了 AES 的工作原理,但我认为如果我有相同的密钥,我应该能够解密用 AES 加密的消息,但看起来我错了。我怎样才能使它正常工作?
finalCipher = AES.new(sKey, AES.MODE_CFB)
message = input()
#Encrypt the message using the cipher
enMessage = message.encode('utf-8')
encMessage = finalCipher.encrypt(enMessage)
print(encMessage)
#Create a new cipher to decrypt the encrypted message, using the same key
otherCipher = AES.new(sKey, AES.MODE_CFB)
print(otherCipher.decrypt(encMessage))
【问题讨论】:
标签: python encryption cryptography aes pycryptodome