@is_connected<EOL><INDENT>def encrypt(self, data, uid=None, cryptographic_parameters=None,<EOL>iv_counter_nonce=None):<DEDENT>
<EOL>if not isinstance(data, six.binary_type):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if uid is not None:<EOL><INDENT>if not isinstance(uid, six.string_types):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>if cryptographic_parameters is not None:<EOL><INDENT>if not isinstance(cryptographic_parameters, dict):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>if iv_counter_nonce is not None:<EOL><INDENT>if not isinstance(iv_counter_nonce, six.binary_type):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>cryptographic_parameters = self._build_cryptographic_parameters(<EOL>cryptographic_parameters<EOL>)<EOL>result = self.proxy.encrypt(<EOL>data,<EOL>uid,<EOL>cryptographic_parameters,<EOL>iv_counter_nonce<EOL>)<EOL>status = result.get('<STR_LIT>')<EOL>if status == enums.ResultStatus.SUCCESS:<EOL><INDENT>return result.get('<STR_LIT:data>'), result.get('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>raise exceptions.KmipOperationFailure(<EOL>status,<EOL>result.get('<STR_LIT>'),<EOL>result.get('<STR_LIT>')<EOL>)<EOL><DEDENT>
Encrypt data using the specified encryption key and parameters.

Args:
    data (bytes): The bytes to encrypt. Required.
    uid (string): The unique ID of the encryption key to use.
        Optional, defaults to None.
    cryptographic_parameters (dict): A dictionary containing various
        cryptographic settings to be used for the encryption.
        Optional, defaults to None.
    iv_counter_nonce (bytes): The bytes to use for the IV/counter/
        nonce, if needed by the encryption algorithm and/or cipher
        mode. Optional, defaults to None.

Returns:
    bytes: The encrypted data.
    bytes: The IV/counter/nonce used with the encryption algorithm,
        only if it was autogenerated by the server.

Raises:
    ClientConnectionNotOpen: if the client connection is unusable
    KmipOperationFailure: if the operation result is a failure
    TypeError: if the input arguments are invalid

Notes:
    The cryptographic_parameters argument is a dictionary that can
    contain the following key/value pairs:

    Keys                          | Value
    ------------------------------|-----------------------------------
    'block_cipher_mode'           | A BlockCipherMode enumeration
                                  | indicating the cipher mode to use
                                  | with the encryption algorithm.
    'padding_method'              | A PaddingMethod enumeration
                                  | indicating which padding method to
                                  | use with the encryption algorithm.
    'hashing_algorithm'           | A HashingAlgorithm enumeration
                                  | indicating which hashing algorithm
                                  | to use.
    'key_role_type'               | A KeyRoleType enumeration
                                  | indicating the intended use of the
                                  | associated cryptographic key.
    'digital_signature_algorithm' | A DigitalSignatureAlgorithm
                                  | enumeration indicating which
                                  | digital signature algorithm to
                                  | use.
    'cryptographic_algorithm'     | A CryptographicAlgorithm
                                  | enumeration indicating which
                                  | encryption algorithm to use.
    'random_iv'                   | A boolean indicating whether the
                                  | server should autogenerate an IV.
    'iv_length'                   | An integer representing the length
                                  | of the initialization vector (IV)
                                  | in bits.
    'tag_length'                  | An integer representing the length
                                  | of the authenticator tag in bytes.
    'fixed_field_length'          | An integer representing the length
                                  | of the fixed field portion of the
                                  | IV in bits.
    'invocation_field_length'     | An integer representing the length
                                  | of the invocation field portion of
                                  | the IV in bits.
    'counter_length'              | An integer representing the length
                                  | of the coutner portion of the IV
                                  | in bits.
    'initial_counter_value'       | An integer representing the
                                  | starting counter value for CTR
                                  | mode (typically 1).