我想在 Python 3.8.5 上使用 AES 256 为我的明文编写加密,但是当我执行它时,我收到错误ValueError:不正确的 AES 密钥长度(64 字节)我的代码中是否有问题?
plaintext = "ABC123"
secret_key = "6789045129812345"
secret_iv = "4567891122315731"
key = hashlib.sha256(str(secret_key).encode('utf-8')).hexdigest()
iv = hashlib.sha256(str(secret_iv).encode('utf-8')).hexdigest()
substring_iv = iv[:16]
cipher_config = AES.new(key.encode("utf-8"), AES.MODE_CBC, substring_iv.encode("utf-8"))
results = base64.b64encode(cipher_config)
print("results : "+results)
Run Code Online (Sandbox Code Playgroud)