fork download
  1. def hexdump(data, width=16):
  2. lines = []
  3. for i in range(0, len(data), width):
  4. chunk = data[i:i+width]
  5. hex_bytes = ' '.join(f'{b:02x}' for b in chunk)
  6. ascii_repr = ''.join(chr(b) if 32 <= b <= 126 else '.' for b in chunk)
  7. lines.append(f"{i:04x} {hex_bytes:<{width*3}} {ascii_repr}")
  8. return "\n".join(lines)
  9.  
  10. data = b"\xc8\x02\x00d\x00\x00\x00\x00\x00\x00\x00\x01\x80\x08\x00\x00\x00\x00\x00\x02\x80\x08\x00\x00\x00\x02\x01\x00\x80\n\x00\x00\x00\x03\x00\x00\x00\x01\x80\n\x00\x00\x00\x04\x00\x00\x00\x00\x00\x08\x00\x00\x00\x06\x00\x01\x80\x0e\x00\x00\x00\x07MikroTik\x00\x0e\x00\x00\x00\x08MikroTik\x80\x08\x00\x00\x00\t\x00\x16\x80\x08\x00\x00\x00\n\x00\x04"
  11.  
  12. print(hexdump(data))
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty