binascii.hexlify()
binascii.hexlify() is a Python function in the Binascii Module category. Converts bytes to hexadecimal representation (like bytes.hex()). The syntax is binascii.hexlify(data, sep=b"", bytes_per_sep=1). Parameters: data — bytes. Returns: Hex bytes. A typical example: import binascii
binascii.hexlify(b"hello") # b"68656c6c6f"
binascii.hexlify(b"hello", b" ", 2) # b"6865 6c6c 6f". A close sibling is binascii.unhexlify(), which converts hexadecimal representation back to bytes. A close sibling is binascii.crc32(), which computes CRC-32 checksum of data (for error detection, not security). A close sibling is binascii.a2b_base64(), which converts base64 ASCII string to bytes (alternative to base64.b64decode). A close sibling is binascii.b2a_base64(), which converts bytes to base64 ASCII string. More about this category: Binary data conversions — hexlify, unhexlify, crc32, base64. Related Binascii Module entries: binascii.unhexlify(), binascii.crc32(), binascii.a2b_base64(), binascii.b2a_base64(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.