mirror of
https://frontier.innolan.net/github/amigaos-cross-toolchain6.git
synced 2024-10-19 10:29:55 +00:00
15 lines
367 B
Python
15 lines
367 B
Python
def hexdump(data):
|
|
hexch = ['%.2x' % ord(c) for c in data]
|
|
|
|
ascii = []
|
|
for c in data:
|
|
if ord(c) >= 32 and ord(c) < 127:
|
|
ascii.append(c)
|
|
else:
|
|
ascii.append('.')
|
|
|
|
for i in range(0, len(hexch), 16):
|
|
hexstr = ' '.join(hexch[i:i + 16])
|
|
asciistr = ''.join(ascii[i:i + 16])
|
|
print ' {0} |{1}|'.format(hexstr.ljust(47, ' '), asciistr)
|