import binascii


def hexlify(data: bytes, with_prefix=False) -> str:
    """Convert bytes data to hexadecimal string."""

    encoded = binascii.hexlify(data).decode('ascii')
    if with_prefix:
        return '0x' + encoded
    return encoded