From a9886b9d52c3bce0a4b58805b5597efccc55225a Mon Sep 17 00:00:00 2001 From: itsme Date: Tue, 6 Jul 2021 19:26:42 +0200 Subject: initial commit --- hexdump.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 hexdump.py (limited to 'hexdump.py') diff --git a/hexdump.py b/hexdump.py new file mode 100644 index 0000000..c119b16 --- /dev/null +++ b/hexdump.py @@ -0,0 +1,27 @@ +import struct +from binascii import b2a_hex +""" +Simple hexdump, 16 bytes per line with offset. +""" + +def ashex(line): + return " ".join("%02x" % _ for _ in line) +def aschr(b): + if 32<=b<0x7f: + return "%c" % b + elif 0x80<=b<=0xff: + try: + c = struct.pack("