def encrypt(self,text):
cryptor = AES.new(self.key,self.mode,b'0000000000000000')
#????key ?????16?AES-128?,
#24?AES-192?,??32 ?AES-256?Bytes ??
#??AES-128 ??????
length = 16
count = len(text)
if count < length:
add = (length-count)
#\0 backspace
text = text + ('\0' * add)
elif count > length:
add = (length-(count % length))
text = text + ('\0' * add)
self.ciphertext = cryptor.encrypt(text)
#??AES??????????????ascii??????????????????????
#?????????????????16?????
return b2a_hex(self.ciphertext)
#????????????strip() ??
评论列表
文章目录