From 9346f86f73f4239cf86c852d5f7bb01c71185d14 Mon Sep 17 00:00:00 2001 From: xxyzz Date: Wed, 27 Jan 2021 14:31:05 +0800 Subject: [PATCH] encode serialnum before returning it, close #1479 --- DeDRM_plugin/kgenpids.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DeDRM_plugin/kgenpids.py b/DeDRM_plugin/kgenpids.py index 9800254..103b77b 100644 --- a/DeDRM_plugin/kgenpids.py +++ b/DeDRM_plugin/kgenpids.py @@ -174,14 +174,14 @@ def pidFromSerial(s, l): # Parse the EXTH header records and use the Kindle serial number to calculate the book pid. def getKindlePids(rec209, token, serialnum): + if isinstance(serialnum,str): + serialnum = serialnum.encode('utf-8') + if rec209 is None: return [serialnum] pids=[] - if isinstance(serialnum,str): - serialnum = serialnum.encode('utf-8') - # Compute book PID pidHash = SHA1(serialnum+rec209+token) bookPID = encodePID(pidHash)