def encrypt(self, payload, client_info, cid, val_type="id_token", cty=""):
        """
        Handles the encryption of a payload.
        Shouldn't get here unless there are encrypt parameters in client info

        :param payload: The information to be encrypted
        :param client_info: Client information
        :param cid: Client id
        :return: The encrypted information as a JWT
        """

        try:
            alg = client_info["%s_encrypted_response_alg" % val_type]
            enc = client_info["%s_encrypted_response_enc" % val_type]
        except KeyError as err:  # both must be defined
            logger.warning("undefined parameter: %s" % err)
            raise JWEException("%s undefined" % err)

        logger.debug("alg=%s, enc=%s, val_type=%s" % (alg, enc, val_type))
        keys = self.keyjar.get_encrypt_key(owner=cid)
        logger.debug("Encryption keys for %s: %s" % (cid, keys))
        try:
            _ckeys = self.keyjar[cid]
        except __HOLE__:
            # Weird, but try to recuperate
            logger.warning(
                "Lost keys for {} trying to recuperate!!".format(cid))
            self.keyjar.issuer_keys[cid] = []
            self.keyjar.add(cid, client_info["jwks_uri"])
            _ckeys = self.keyjar[cid]

        logger.debug("keys for %s: %s" % (
            cid, "[" + ", ".join([str(x) for x in _ckeys])) + "]")

        kwargs = {"alg": alg, "enc": enc}
        if cty:
            kwargs["cty"] = cty

        # use the clients public key for encryption
        _jwe = JWE(payload, **kwargs)
        return _jwe.encrypt(keys, context="public")
dataset/ETHPy150Open rohe/pyoidc/src/oic/oic/provider.py/Provider.encrypt