hexrec.utils.hexlify#

hexrec.utils.hexlify(data, width=None, sep='', newline='\\n', window=2, upper=True)[source]#

Splits ans wraps byte data into hexadecimal columns.

A chunk of byte data is converted into a hexadecimal text line, and then columnized as per columnize().

Parameters:
  • data (bytes) – Byte data.

  • width (int) – Maximum line width, or None.

  • sep (str) – Column separator string.

  • newline (str) – Line separator string.

  • window (int) – Splitted column length.

  • upper (bool) – Uppercase hexadecimal digits.

Returns:

str – A wrapped and columnized hexadecimal representation of the data.

Example

>>> hexlify(b'Hello, World!', sep='.')
'48.65.6C.6C.6F.2C.20.57.6F.72.6C.64.21'
>>> hexlify(b'Hello, World!', 6, ' ')
'48 65 6C\n6C 6F 2C\n20 57 6F\n72 6C 64\n21'