Skip to content

Commit 1a68a51

Browse files
author
anatoliis
committed
Fixes padding stripping in Python2
1 parent 9bda56e commit 1a68a51

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

yoti/crypto.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,12 @@ def decipher(key, iv, cipher_text):
6565

6666
@staticmethod
6767
def strip_pkcs5_padding(data):
68+
if isinstance(data, str):
69+
data = bytearray(data)
70+
6871
number_of_padded_bytes = data[-1]
69-
return data[:-number_of_padded_bytes]
72+
stripped = data[:-number_of_padded_bytes]
73+
74+
if isinstance(stripped, bytearray):
75+
stripped = str(stripped)
76+
return stripped

0 commit comments

Comments
 (0)