【发布时间】:2017-03-24 18:52:42
【问题描述】:
所以我现在正在尝试在 Python 中创建一个简单的 AES 加密/解密系统......但是当它解密时,它在解密的字符串前面有一堆 /xxx/xxx/xxx/xxx/。如何清理它并使其仅打印明文。
我的代码是:
import base64
from Crypto.Cipher import AES
from Crypto import Random
key = b'Sixteen byte key'
iv = Random.new().read(AES.block_size)
cipher = AES.new(key, AES.MODE_CFB, iv)
msg = iv + cipher.encrypt(b'Attack at dawn...')
print (msg)
print (base64.b64encode(msg))
print (cipher.decrypt(msg))
decrypt 的输出如下所示:
b'\xfb\xb8\xf0\xc3\xffH\xfc~\x19[\xecy?\xf8\xcc\x80Attack at dawn...'
【问题讨论】:
-
你能分享你得到的输出吗?
标签: python python-3.x encryption cryptography pycrypto