我正在尝试加密字符串。但是得到这个错误:-你知道吗
ValueError: AES key must be either 16, 24, or 32 bytes long
from Crypto.Cipher import AES
import hashlib
key = 'E61EFD66173C8A58132B84E43566AB4826533F4483968BA58C9C4739FFD25FAD'
firstByte = key[0:32]
lastByte = key[32:64]
hexfirstByte = firstByte.encode()
hexlastByte = lastByte.encode()
# xorNumber = int(firstByte,2) ^ int(lastByte,2)
xorNumber = hex(int(firstByte,16) ^ int(lastByte,16))
hexNumber = bytes(xorNumber, 'utf-8')
IV = 16 * '\x00'
mode = AES.MODE_CBC
encryptor = AES.new(hexNumber, mode, IV=IV)
text = 'j' * 64 + 'i' * 128
ciphertext = encryptor.encrypt(text)
decryptor = AES.new(hexNumber, mode, IV=IV)
plain = decryptor.decrypt(ciphertext)
print("decript" + str(plain))
目前没有回答
相关问题 更多 >
编程相关推荐