]> xmof Git - DeDRM.git/commitdiff
Update ineptpdf.py
authorApprentice Harper <apprenticeharper@gmail.com>
Sun, 3 Jan 2021 16:11:02 +0000 (16:11 +0000)
committerApprentice Harper <apprenticeharper@gmail.com>
Sun, 3 Jan 2021 16:11:02 +0000 (16:11 +0000)
integer division, and version

DeDRM_plugin/__init__.py
DeDRM_plugin/ineptpdf.py

index 1e9c2e5f8e33b5ca337cb823658d4f947037feb9..f4be36d44f342f174470c9dab4f0aa1c5c6339f0 100644 (file)
@@ -5,7 +5,7 @@
 # Copyright © 2008-2020 Apprentice Harper et al.
 
 __license__   = 'GPL v3'
-__version__ = '7.0.2'
+__version__ = '7.0.3'
 __docformat__ = 'restructuredtext en'
 
 
@@ -73,6 +73,7 @@ __docformat__ = 'restructuredtext en'
 #   7.0.0 - Switched to Python 3 for calibre 5.0. Thanks to all who contributed
 #   7.0.1 - More Python 3 changes. Adobe PDF decryption should now work in some cases
 #   7.0.2 - More Python 3 changes. Adobe PDF decryption should now work on PC too.
+#   7.0.3 - More Python 3 changes. Integer division in ineptpdf.py
 
 """
 Decrypt DRMed ebooks.
index f0ebbc824fd6627b0bdca202c24681e84b5c9d9f..17ccdcff63d89ce1aa63c835330e865456cdec78 100755 (executable)
@@ -1482,7 +1482,7 @@ class PDFDocument(object):
         # global static principal key for German Onleihe / Bibliothek Digital
         principalkeys = { b'bibliothek-digital.de': codecs.decode(b'rRwGv2tbpKov1krvv7PO0ws9S436/lArPlfipz5Pqhw=','base64')}
         self.is_printable = self.is_modifiable = self.is_extractable = True
-        length = int_value(param.get('Length', 0)) / 8
+        length = int_value(param.get('Length', 0)) // 8
         edcdata = str_value(param.get('EDCData')).decode('base64')
         pdrllic = str_value(param.get('PDRLLic')).decode('base64')
         pdrlpol = str_value(param.get('PDRLPol')).decode('base64')
@@ -1547,8 +1547,8 @@ class PDFDocument(object):
         if 5 <= R:
             # 8
             for _ in range(50):
-                hash = hashlib.md5(hash.digest()[:length/8])
-        key = hash.digest()[:length/8]
+                hash = hashlib.md5(hash.digest()[:length//8])
+        key = hash.digest()[:length//8]
         if R == 2:
             # Algorithm 3.4
             u1 = ARC4.new(key).decrypt(password)
@@ -1590,7 +1590,7 @@ class PDFDocument(object):
     def initialize_ebx(self, password, docid, param):
         self.is_printable = self.is_modifiable = self.is_extractable = True
         rsa = RSA(password)
-        length = int_value(param.get('Length', 0)) / 8
+        length = int_value(param.get('Length', 0)) // 8
         rights = codecs.decode(param.get('ADEPT_LICENSE'), 'base64')
         rights = zlib.decompress(rights, -15)
         rights = etree.fromstring(rights)