'Will encrypt an assertion
:param statement: A XML document that contains the assertion to encrypt
:param enc_key: File name of a file containing the encryption key
:param template: A template for the encryption part to be added.
:param key_type: The type of session key to use.
:return: The encrypted text'

def encrypt_assertion(self, statement, enc_key, template, key_type='des-192', node_xpath=None):

    if isinstance(statement, SamlBase):
        statement = pre_encrypt_assertion(statement)
    (_, fil) = make_temp(('%s' % statement), decode=False, delete=False)
    (_, tmpl) = make_temp(('%s' % template), decode=False)
    if (not node_xpath):
        node_xpath = ASSERT_XPATH
    com_list = [self.xmlsec, 'encrypt', '--pubkey-cert-pem', enc_key, '--session-key', key_type, '--xml-data', fil, '--node-xpath', node_xpath]
    (_stdout, _stderr, output) = self._run_xmlsec(com_list, [tmpl], exception=EncryptError, validate_output=False)
    os.unlink(fil)
    if (not output):
        raise EncryptError(_stderr)
    return output
