Add back unpad to fix Python2 support

This commit is contained in:
NoDRM
2022-03-19 10:14:45 +01:00
parent cf095a4171
commit b283777c0a
10 changed files with 109 additions and 29 deletions

View File

@@ -75,11 +75,19 @@ from uuid import UUID
try:
from Cryptodome.Cipher import AES, ARC4, PKCS1_v1_5
from Cryptodome.PublicKey import RSA
from Cryptodome.Util.Padding import unpad
except ImportError:
from Crypto.Cipher import AES, ARC4, PKCS1_v1_5
from Crypto.PublicKey import RSA
from Crypto.Util.Padding import unpad
def unpad(data, padding=16):
if sys.version_info[0] == 2:
pad_len = ord(data[-1])
else:
pad_len = data[-1]
return data[:-pad_len]
# Wrap a stream so that output gets flushed immediately
# and also make sure that any unicode strings get