def encode_value(value, flags=None, base64=False):
    """Mostly used by payloads
    """
    if flags:
        # still a no-operation
        logger.debug("Flag %s encoding not implemented yet" % flags)
    if not isinstance(value, bytes):
        raise ValueError("value must be bytes")
    return b64encode(value) if base64 else value
Mostly used by payloads