AES加密解密数据格式转化base64

from Crypto.Cipher import AES import base64 def AESencry(text,y='abc'): if len(y)>=16: y=y[0:16] else: n=16-len(y) y=y+'0'*n print('密钥是',y) y=y.encode() iv = b'0123456789101112' text=text.encode() print('文本encode是',text) length=16 count=len(text) if count < length: add = (length - count) text = text + ('\0' * add).encode() elif count > length: add = (length - (count % length)) text = text + ('\0' * add).encode() print('文本填充后:',text) aes = AES.new(y,AES.MODE_CBC,iv) encryText=aes.encrypt(text) print('AES二进制加密>>>',encryText) encryText = base64.b64encode(encryText) print('AES加密base64>>>',encryText) encryText = encryText.decode() print('AES加密base64字符串>>>',encryText) return encryText a='wo yao jiami' b=AESencry(a)