From f7b4efc3e143446619abee1a9db080cb80952a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Vanicat?= Date: Fri, 8 May 2020 17:57:28 +0200 Subject: [PATCH] More handling of difference between python2 and python3 Place where python3 use bytes/int and python2 str/str --- DeDRM_plugin/ineptepub.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/DeDRM_plugin/ineptepub.py b/DeDRM_plugin/ineptepub.py index e3815e7..839e067 100644 --- a/DeDRM_plugin/ineptepub.py +++ b/DeDRM_plugin/ineptepub.py @@ -210,7 +210,7 @@ def _load_crypto_libcrypto(): def decrypt(self, data): out = create_string_buffer(len(data)) - iv = ("\x00" * self._blocksize) + iv = (b"\x00" * self._blocksize) rv = AES_cbc_encrypt(data, out, len(data), self._key, iv, 0) if rv == 0: raise ADEPTError('AES decryption failed') @@ -371,7 +371,7 @@ class Decryptor(object): def decompress(self, bytes): dc = zlib.decompressobj(-15) bytes = dc.decompress(bytes) - ex = dc.decompress('Z') + dc.flush() + ex = dc.decompress(b'Z') + dc.flush() if ex: bytes = bytes + ex return bytes @@ -379,7 +379,11 @@ class Decryptor(object): def decrypt(self, path, data): if path.encode('utf-8') in self._encrypted: data = self._aes.decrypt(data)[16:] - data = data[:-ord(data[-1])] + if type(data[-1]) != int: + place = ord(data[-1]) + else: + place = data[-1] + data = data[:-place] data = self.decompress(data) return data