summaryrefslogtreecommitdiffstats
path: root/DeDRM_plugin/kindlekey.py
diff options
context:
space:
mode:
authorNoDRM <[email protected]>2023-08-03 10:50:06 +0200
committerNoDRM <[email protected]>2023-08-03 11:26:05 +0200
commite509b7d520d044a830c5e56ac75493142d05445d (patch)
treef2e8cbd2f2af020552a3121b48963ba5b226f75b /DeDRM_plugin/kindlekey.py
parente82d2b5c9cd799f0c4a1349dbcf0487a115fecaa (diff)
Fix python2 issues in kgenpids and kindlekey
Diffstat (limited to 'DeDRM_plugin/kindlekey.py')
-rw-r--r--DeDRM_plugin/kindlekey.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/DeDRM_plugin/kindlekey.py b/DeDRM_plugin/kindlekey.py
index 14e4ed1..e8a0e65 100644
--- a/DeDRM_plugin/kindlekey.py
+++ b/DeDRM_plugin/kindlekey.py
@@ -115,11 +115,17 @@ def primes(n):
def encode(data, map):
result = b''
for char in data:
- value = char
+ if sys.version_info[0] == 2:
+ value = ord(char)
+ else:
+ value = char
+
Q = (value ^ 0x80) // len(map)
R = value % len(map)
- result += bytes([map[Q]])
- result += bytes([map[R]])
+
+ result += bytes(bytearray([map[Q]]))
+ result += bytes(bytearray([map[R]]))
+
return result
# Hash the bytes in data and then encode the digest with the characters in map