Closed
Description
Hi,
I'm sorry, but my pull request #15 was incomplete. What makes -c
work with Python 3.5 is the following patch:
diff --git a/xortool/routine.py b/xortool/routine.py
index 98f353a..9e760f1 100644
--- a/xortool/routine.py
+++ b/xortool/routine.py
@@ -76,7 +76,7 @@ def dexor(text, key):
ret = list(text)
mod = len(key)
for index, char in enumerate(ret):
- ret[index] = chr(ord(char) ^ ord(key[index % mod]))
+ ret[index] = chr(char ^ ord(key[index % mod]))
return "".join(ret)
diff --git a/xortool/xortool b/xortool/xortool
index c9fd0aa..2fcbc97 100755
--- a/xortool/xortool
+++ b/xortool/xortool
@@ -271,7 +271,7 @@ def guess_keys(text, most_char):
max_count = max(chars_count.values())
for char in chars_count:
if chars_count[char] >= max_count:
- key_possible_bytes[offset].append(chr(ord(char) ^ most_char))
+ key_possible_bytes[offset].append(chr(char ^ most_char))
return all_keys(key_possible_bytes)
@@ -358,7 +358,7 @@ def produce_plaintexts(ciphertext, keys, key_char_used):
repr(key_char_used[key]),
perc))
f = open(file_name, "wb")
- f.write(dexored)
+ f.write(dexored.encode())
f.close()
key_mapping.close()
perc_mapping.close()
Unfortunately (at least) the first two hunks break Python 2 compatibility and so far I haven't figured out how to make it work with both Python generations.
And I'm not 100% sure if appending that .encode()
is the correct fix, but at least I get the same results on the same input data plus command-line parameters.
Metadata
Metadata
Assignees
Labels
No labels