From f6cc7046a246c2af029875df6d8e4fbaeeec0eb2 Mon Sep 17 00:00:00 2001 From: Aaron3S Date: Mon, 26 Sep 2022 20:34:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A9=BA=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E5=8A=A0=E5=AF=86=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/sdk/gm/piico/cipher.py | 2 +- apps/common/utils/crypto.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/common/sdk/gm/piico/cipher.py b/apps/common/sdk/gm/piico/cipher.py index 7f3a0b7b0..250e19d9b 100644 --- a/apps/common/sdk/gm/piico/cipher.py +++ b/apps/common/sdk/gm/piico/cipher.py @@ -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 diff --git a/apps/common/utils/crypto.py b/apps/common/utils/crypto.py index 1407c7d7d..b39dedad8 100644 --- a/apps/common/utils/crypto.py +++ b/apps/common/utils/crypto.py @@ -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):