(src, length=16, prefix='')
return "\n".join(result)
Print hexdump of string

    >>> print(hexdump(b"abcd" * 4))
    0000  61 62 63 64 61 62 63 64  61 62 63 64 61 62 63 64  abcdabcd abcdabcd

    >>> print(hexdump(bytearray(range(48))))
    0000  00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f  ........ ........
    0010  10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f  ........ ........
    0020  20 21 22 23 24 25 26 27  28 29 2a 2b 2c 2d 2e 2f   !"#$%&' ()*+,-./
Print hexdump of string
Print hexdump of string
def hexdump(src, length=16, prefix=''):
    """
    Print hexdump of string

    >>> print(hexdump(b"abcd" * 4))
    0000  61 62 63 64 61 62 63 64  61 62 63 64 61 62 63 64  abcdabcd abcdabcd

    >>> print(hexdump(bytearray(range(48))))
    0000  00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f  ........ ........
    0010  10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f  ........ ........
    0020  20 21 22 23 24 25 26 27  28 29 2a 2b 2c 2d 2e 2f   !"#$%&' ()*+,-./

    """
    n = 0
    left = length // 2 
    right = length - left
    result= []
    src = bytearray(src)
    while src:
        s,src = src[:length],src[length:]
        l,r = s[:left],s[left:]
        hexa = "%-*s" % (left*3,' '.join(["%02x"%x for x in l]))
        hexb = "%-*s" % (right*3,' '.join(["%02x"%x for x in r]))
        lf = l.translate(FILTER)
        rf = r.translate(FILTER)
        result.append("%s%04x  %s %s %s %s" % (prefix, n, hexa, hexb, 
                                               lf.decode(), rf.decode()))
        n += length
    return "\n".join(result)
def hexdump ( src , length = 16 , prefix = '' ) : n = 0 left = length // 2 right = length - left result = [ ] src = bytearray ( src ) while src : s , src = src [ : length ] , src [ length : ] l , r = s [ : left ] , s [ left : ] hexa = "%-*s" % ( left * 3 , ' ' . join ( [ "%02x" % x for x in l ] ) ) hexb = "%-*s" % ( right * 3 , ' ' . join ( [ "%02x" % x for x in r ] ) ) lf = l . translate ( FILTER ) rf = r . translate ( FILTER ) result . append ( "%s%04x  %s %s %s %s" % ( prefix , n , hexa , hexb , lf . decode ( ) , rf . decode ( ) ) ) n += length return "\n" . join ( result )