@is_connected
def encrypt(self, data, uid=None, cryptographic_parameters=None, iv_counter_nonce=None):
    "\n        Encrypt data using the specified encryption key and parameters.\n\n        Args:\n            data (bytes): The bytes to encrypt. Required.\n            uid (string): The unique ID of the encryption key to use.\n                Optional, defaults to None.\n            cryptographic_parameters (dict): A dictionary containing various\n                cryptographic settings to be used for the encryption.\n                Optional, defaults to None.\n            iv_counter_nonce (bytes): The bytes to use for the IV/counter/\n                nonce, if needed by the encryption algorithm and/or cipher\n                mode. Optional, defaults to None.\n\n        Returns:\n            bytes: The encrypted data.\n            bytes: The IV/counter/nonce used with the encryption algorithm,\n                only if it was autogenerated by the server.\n\n        Raises:\n            ClientConnectionNotOpen: if the client connection is unusable\n            KmipOperationFailure: if the operation result is a failure\n            TypeError: if the input arguments are invalid\n\n        Notes:\n            The cryptographic_parameters argument is a dictionary that can\n            contain the following key/value pairs:\n\n            Keys                          | Value\n            ------------------------------|-----------------------------------\n            'block_cipher_mode'           | A BlockCipherMode enumeration\n                                          | indicating the cipher mode to use\n                                          | with the encryption algorithm.\n            'padding_method'              | A PaddingMethod enumeration\n                                          | indicating which padding method to\n                                          | use with the encryption algorithm.\n            'hashing_algorithm'           | A HashingAlgorithm enumeration\n                                          | indicating which hashing algorithm\n                                          | to use.\n            'key_role_type'               | A KeyRoleType enumeration\n                                          | indicating the intended use of the\n                                          | associated cryptographic key.\n            'digital_signature_algorithm' | A DigitalSignatureAlgorithm\n                                          | enumeration indicating which\n                                          | digital signature algorithm to\n                                          | use.\n            'cryptographic_algorithm'     | A CryptographicAlgorithm\n                                          | enumeration indicating which\n                                          | encryption algorithm to use.\n            'random_iv'                   | A boolean indicating whether the\n                                          | server should autogenerate an IV.\n            'iv_length'                   | An integer representing the length\n                                          | of the initialization vector (IV)\n                                          | in bits.\n            'tag_length'                  | An integer representing the length\n                                          | of the authenticator tag in bytes.\n            'fixed_field_length'          | An integer representing the length\n                                          | of the fixed field portion of the\n                                          | IV in bits.\n            'invocation_field_length'     | An integer representing the length\n                                          | of the invocation field portion of\n                                          | the IV in bits.\n            'counter_length'              | An integer representing the length\n                                          | of the coutner portion of the IV\n                                          | in bits.\n            'initial_counter_value'       | An integer representing the\n                                          | starting counter value for CTR\n                                          | mode (typically 1).\n        "
    if (not isinstance(data, six.binary_type)):
        raise TypeError('data must be bytes')
    if (uid is not None):
        if (not isinstance(uid, six.string_types)):
            raise TypeError('uid must be a string')
    if (cryptographic_parameters is not None):
        if (not isinstance(cryptographic_parameters, dict)):
            raise TypeError('cryptographic_parameters must be a dict')
    if (iv_counter_nonce is not None):
        if (not isinstance(iv_counter_nonce, six.binary_type)):
            raise TypeError('iv_counter_nonce must be bytes')
    cryptographic_parameters = self._build_cryptographic_parameters(cryptographic_parameters)
    result = self.proxy.encrypt(data, uid, cryptographic_parameters, iv_counter_nonce)
    status = result.get('result_status')
    if (status == enums.ResultStatus.SUCCESS):
        return (result.get('data'), result.get('iv_counter_nonce'))
    else:
        raise exceptions.KmipOperationFailure(status, result.get('result_reason'), result.get('result_message'))
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).
@is_connected
def encrypt(self, data, uid=None, cryptographic_parameters=None, iv_counter_nonce=None):
    "\n        Encrypt data using the specified encryption key and parameters.\n\n        Args:\n            data (bytes): The bytes to encrypt. Required.\n            uid (string): The unique ID of the encryption key to use.\n                Optional, defaults to None.\n            cryptographic_parameters (dict): A dictionary containing various\n                cryptographic settings to be used for the encryption.\n                Optional, defaults to None.\n            iv_counter_nonce (bytes): The bytes to use for the IV/counter/\n                nonce, if needed by the encryption algorithm and/or cipher\n                mode. Optional, defaults to None.\n\n        Returns:\n            bytes: The encrypted data.\n            bytes: The IV/counter/nonce used with the encryption algorithm,\n                only if it was autogenerated by the server.\n\n        Raises:\n            ClientConnectionNotOpen: if the client connection is unusable\n            KmipOperationFailure: if the operation result is a failure\n            TypeError: if the input arguments are invalid\n\n        Notes:\n            The cryptographic_parameters argument is a dictionary that can\n            contain the following key/value pairs:\n\n            Keys                          | Value\n            ------------------------------|-----------------------------------\n            'block_cipher_mode'           | A BlockCipherMode enumeration\n                                          | indicating the cipher mode to use\n                                          | with the encryption algorithm.\n            'padding_method'              | A PaddingMethod enumeration\n                                          | indicating which padding method to\n                                          | use with the encryption algorithm.\n            'hashing_algorithm'           | A HashingAlgorithm enumeration\n                                          | indicating which hashing algorithm\n                                          | to use.\n            'key_role_type'               | A KeyRoleType enumeration\n                                          | indicating the intended use of the\n                                          | associated cryptographic key.\n            'digital_signature_algorithm' | A DigitalSignatureAlgorithm\n                                          | enumeration indicating which\n                                          | digital signature algorithm to\n                                          | use.\n            'cryptographic_algorithm'     | A CryptographicAlgorithm\n                                          | enumeration indicating which\n                                          | encryption algorithm to use.\n            'random_iv'                   | A boolean indicating whether the\n                                          | server should autogenerate an IV.\n            'iv_length'                   | An integer representing the length\n                                          | of the initialization vector (IV)\n                                          | in bits.\n            'tag_length'                  | An integer representing the length\n                                          | of the authenticator tag in bytes.\n            'fixed_field_length'          | An integer representing the length\n                                          | of the fixed field portion of the\n                                          | IV in bits.\n            'invocation_field_length'     | An integer representing the length\n                                          | of the invocation field portion of\n                                          | the IV in bits.\n            'counter_length'              | An integer representing the length\n                                          | of the coutner portion of the IV\n                                          | in bits.\n            'initial_counter_value'       | An integer representing the\n                                          | starting counter value for CTR\n                                          | mode (typically 1).\n        "
    if (not isinstance(data, six.binary_type)):
        raise TypeError('data must be bytes')
    if (uid is not None):
        if (not isinstance(uid, six.string_types)):
            raise TypeError('uid must be a string')
    if (cryptographic_parameters is not None):
        if (not isinstance(cryptographic_parameters, dict)):
            raise TypeError('cryptographic_parameters must be a dict')
    if (iv_counter_nonce is not None):
        if (not isinstance(iv_counter_nonce, six.binary_type)):
            raise TypeError('iv_counter_nonce must be bytes')
    cryptographic_parameters = self._build_cryptographic_parameters(cryptographic_parameters)
    result = self.proxy.encrypt(data, uid, cryptographic_parameters, iv_counter_nonce)
    status = result.get('result_status')
    if (status == enums.ResultStatus.SUCCESS):
        return (result.get('data'), result.get('iv_counter_nonce'))
    else:
        raise exceptions.KmipOperationFailure(status, result.get('result_reason'), result.get('result_message'))