MCPcopy Index your code
hub / github.com/secdev/scapy / chexdump

Function chexdump

scapy/utils.py:360–378  ·  view source on GitHub ↗

Build a per byte hexadecimal representation Example: >>> chexdump(IP()) 0x45, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x7c, 0xe7, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01 # noqa: E501 :param p: a Packet :param dump: print the view if False :retu

(p, dump=False)

Source from the content-addressed store, hash-verified

358
359@conf.commands.register
360def chexdump(p, dump=False):
361 # type: (Union[Packet, AnyStr], bool) -> Optional[str]
362 """Build a per byte hexadecimal representation
363
364 Example:
365 >>> chexdump(IP())
366 0x45, 0x00, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x7c, 0xe7, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, 0x00, 0x01 # noqa: E501
367
368 :param p: a Packet
369 :param dump: print the view if False
370 :return: a String only if dump=True
371 """
372 x = bytes_encode(p)
373 s = ", ".join("%#04x" % orb(x) for x in x)
374 if dump:
375 return s
376 else:
377 print(s)
378 return None
379
380
381@conf.commands.register

Callers

nothing calls this directly

Calls 3

bytes_encodeFunction · 0.90
orbFunction · 0.90
joinMethod · 0.80

Tested by

no test coverage detected