unhexlify#
- hexrec.utils.unhexlify(hexstr, delete=None)[source]#
Converts a hexadecimal byte string into raw bytes.
If delete, its byte values are deleted from hexstr before evaluation. Useful to remove whitespace and separators.
- Parameters:
hexstr (bytes) – Source hexadecimal byte string.
delete (bytes) – If empty or
None
, no deletion occurs. IfEllipsis
,DEFAULT_DELETE
is used.
- Returns:
bytes – Raw byte string.
Examples
>>> from hexrec.utils import unhexlify >>> unhexlify(b'AABBCC') b'\xaa\xbb\xcc' >>> unhexlify(b'AA BB CC', delete=...) b'\xaa\xbb\xcc' >>> unhexlify(b'AA-BB-CC', delete=...) b'\xaa\xbb\xcc' >>> unhexlify(b'AA/BB/CC', delete=b'/') b'\xaa\xbb\xcc'