Provided by: libmongoc-doc_2.2.0-1_all bug

SYNOPSIS

          bool
          mongoc_client_encryption_encrypt (
             mongoc_client_encryption_t *client_encryption,
             const bson_value_t *value,
             mongoc_client_encryption_encrypt_opts_t *opts,
             bson_value_t *ciphertext,
             bson_error_t *error);

       Performs explicit encryption.

       ciphertext  is  always  initialized (even on failure). Caller must call bson_value_destroy() <https://www
       .mongoc.org/libbson/current/bson_value_destroy.html> to free.

       To insert or query with an "Indexed" or "Range" encrypted payload, use a  mongoc_client_t  <>  configured
       with  mongoc_auto_encryption_opts_t  <>. The mongoc_auto_encryption_opts_t <> may be configured to bypass
       query     analysis     with     mongoc_auto_encryption_opts_set_bypass_query_analysis()     <>.       The
       mongoc_auto_encryption_opts_t   <>   must   not   be  configured  to  bypass  automatic  encryption  with
       mongoc_auto_encryption_opts_set_bypass_auto_encryption() <>.

       To insert with a Range payload mongoc_client_encryption_encrypt_range_opts_t <> must be set in opts.

       To query with a Range payload, use mongoc_client_encryption_encrypt_expression() <>

PARAMETERS

client_encryption: A mongoc_client_encryption_t <>

       • value: The value to encrypt.

       • opts: A mongoc_client_encryption_encrypt_opts_t <>.

       • ciphertext: A bson_value_t <https://www.mongoc.org/libbson/current/bson_value_t.html> for the resulting
         ciphertext (a BSON binary with subtype 6).

       • error: A bson_error_t <https://www.mongoc.org/libbson/current/bson_error_t.html> set on failure.

RETURNS

       Returns true if successful. Returns false and sets error otherwise.

       See also:
          mongoc_client_encryption_encrypt_opts_t <>

          mongoc_client_enable_auto_encryption() <>

          mongoc_client_decryption_decrypt() <>

          mongoc_client_encryption_encrypt_expression() <>

Author

       MongoDB, Inc

Copyright

       2009-present, MongoDB, Inc.

2.2.0                                             Nov 26, 2025               MONGOC_CLIENT_ENCRYPTION_ENCRYPT(3)