summaryrefslogtreecommitdiff
path: root/hexdump.py
diff options
context:
space:
mode:
Diffstat (limited to 'hexdump.py')
-rw-r--r--hexdump.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/hexdump.py b/hexdump.py
index c119b16..aeb8c88 100644
--- a/hexdump.py
+++ b/hexdump.py
@@ -1,9 +1,16 @@
1import struct 1import struct
2from binascii import b2a_hex 2from binascii import b2a_hex, a2b_hex
3""" 3"""
4Simple hexdump, 16 bytes per line with offset. 4Simple hexdump, 16 bytes per line with offset.
5""" 5"""
6 6
7def unhex(data):
8 if type(data)==bytes:
9 data = data.decode('ascii')
10 data = data.replace(' ', '')
11 data = data.strip()
12 return a2b_hex(data)
13
7def ashex(line): 14def ashex(line):
8 return " ".join("%02x" % _ for _ in line) 15 return " ".join("%02x" % _ for _ in line)
9def aschr(b): 16def aschr(b):