From 87ab94b98006b31c9cedd134c51febd9c5394f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=93=B2=E9=AA=81?= Date: Sun, 19 Nov 2017 20:37:15 +0800 Subject: [PATCH] bug fix, pad zeros for hex --- aria2_to_magnet.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aria2_to_magnet.py b/aria2_to_magnet.py index 363dd4b..21d5630 100644 --- a/aria2_to_magnet.py +++ b/aria2_to_magnet.py @@ -61,7 +61,8 @@ def parse_aria_control_file(file_name): hash_binary = f.read(hash_length) info_hash = "" for ch in hash_binary: - hex_word = hex(ord(ch))[2:] + hex_word = hex(ord(ch))[2:].zfill(2) + print hex_word info_hash += hex_word.upper() @@ -78,4 +79,4 @@ if __name__ == '__main__': parse_aria_control_file(file_name) # version is 1 # hash length is 20 - # magnet:?xt=urn:btih:959E2ECEB954313D3869EFF7924CA7CD8DE739 + # magnet:?xt=urn:btih:959E2ECEB954313D38690EFF7924CA7CD80DE739