Skip to content

Commit a38a9b2

Browse files
authored
Auto-pad hex in conversion as needed
1 parent 682fa64 commit a38a9b2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ProperTree.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,14 @@ def convert_values(self, event = None):
12141214
self.f_text.delete(0,tk.END)
12151215
self.f_text.insert(0,from_value)
12161216
from_value = base64.b64decode(self.get_bytes(from_value))
1217-
elif from_type in ["hex","decimal"]:
1217+
elif from_type in ("hex","decimal"):
1218+
if len(from_value) % 2:
1219+
# Ensure we pad our hex
1220+
from_value = "0"+from_value
1221+
# Reflect it visually for all cases that need it
1222+
if to_type not in ("hex","decimal"):
1223+
self.f_text.delete(0,tk.END)
1224+
self.f_text.insert(0,from_value)
12181225
from_value = binascii.unhexlify(self.get_bytes(from_value))
12191226
# Let's get the data converted
12201227
to_value = self.get_bytes(from_value)

0 commit comments

Comments
 (0)