fix: 修复空字符串加密报错的问题

pull/8910/head
Aaron3S 2022-09-26 20:34:59 +08:00 committed by Jiangjie.Bai
parent 1bc6e50b06
commit f6cc7046a2
2 changed files with 3 additions and 1 deletions

View File

@ -33,7 +33,7 @@ class EBCCipher:
def __padding(val):
# padding
val = bytes(val)
while len(val) % 16 != 0:
while len(val) == 0 or len(val) % 16 != 0:
val += b'\0'
return val

View File

@ -233,6 +233,8 @@ class Crypto:
return self.cryptos[0]
def encrypt(self, text):
if text is None:
return text
return self.encryptor.encrypt(text)
def decrypt(self, text):