def hexdump(buf, length=16):
    n = 0
    res = []
    while buf:
        line, buf = buf[:length], buf[length:]
        hexa = ' '.join(['%02x' % ord(x) for x in line])
        line = line.translate(__vis_filter)
        res.append('  %04d:  %-*s %s' % (n, length * 3, hexa, line))
        n += length
    return '\n'.join(res)
Return a hexdump output string of the given buffer.
dataset/ETHPy150Open kbandla/dpkt/dpkt/dpkt.py/hexdump