typedargs/types/bytes.py
def format_hexdump(arg):
    """Convert the bytes object to a hexdump.

    The output format will be:

    <offset, 4-byte>  <16-bytes of output separated by 1 space>  <16 ascii characters>
    """

    line = ''

    for i in range(0, len(arg), 16):
        if i > 0:
            line += '\n'
        chunk = arg[i:i + 16]
        hex_chunk = hexlify(chunk).decode('utf-8')
        hex_line = ' '.join(hex_chunk[j:j + 2] for j in range(0, len(hex_chunk), 2))

        if len(hex_line) < (3 * 16) - 1:
            hex_line += ' ' * (((3 * 16) - 1) - len(hex_line))

        ascii_line = ''.join(_convert_to_ascii(x) for x in chunk)
        offset_line = '%08x' % i

        line += "%s  %s  %s" % (offset_line, hex_line, ascii_line)

    return line
def format_hexdump(arg):
    """Convert the bytes object to a hexdump.

    The output format will be:

    <offset, 4-byte>  <16-bytes of output separated by 1 space>  <16 ascii characters>
    """

    line = ''

    for i in range(0, len(arg), 16):
        if i > 0:
            line += '\n'
        chunk = arg[i:i + 16]
        hex_chunk = hexlify(chunk).decode('utf-8')
        hex_line = ' '.join(hex_chunk[j:j + 2] for j in range(0, len(hex_chunk), 2))

        if len(hex_line) < (3 * 16) - 1:
            hex_line += ' ' * (((3 * 16) - 1) - len(hex_line))

        ascii_line = ''.join(_convert_to_ascii(x) for x in chunk)
        offset_line = '%08x' % i

        line += "%s  %s  %s" % (offset_line, hex_line, ascii_line)

    return line
def format_hexdump ( arg ) : line = '' for i in range ( 0 , len ( arg ) , 16 ) : if i > 0 : line += '\n' chunk = arg [ i : i + 16 ] hex_chunk = hexlify ( chunk ) . decode ( 'utf-8' ) hex_line = ' ' . join ( hex_chunk [ j : j + 2 ] for j in range ( 0 , len ( hex_chunk ) , 2 ) ) if len ( hex_line ) < ( 3 * 16 ) - 1 : hex_line += ' ' * ( ( ( 3 * 16 ) - 1 ) - len ( hex_line ) ) ascii_line = '' . join ( _convert_to_ascii ( x ) for x in chunk ) offset_line = '%08x' % i line += "%s  %s  %s" % ( offset_line , hex_line , ascii_line ) return line
Convert the bytes object to a hexdump.

    The output format will be:

    <offset, 4-byte>  <16-bytes of output separated by 1 space>  <16 ascii characters>
Convert the bytes object to a hexdump .