You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can also specify an automatic encryption schema for
167
+
server-side field level encryption. To view a full example,
168
+
see the :github:`Server-Side Field Level Encryption Enforcement <mongodb/mongo-cxx-driver/blob/master/examples/mongocxx/server_side_field_level_encryption_enforcement.cpp>`
169
+
example in the driver source code.
170
+
171
+
.. _cpp-csfle-explicit:
172
+
173
+
Configure Explicit Encryption
174
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175
+
176
+
Explicit encryption allows you to perform encrypted operations
177
+
by using the driver's encryption library. To use explicit encryption,
178
+
you must specify the encryption logic throughout your application.
179
+
180
+
The following example configures explicit encryption
181
+
for an insert operation, which inserts an encrypted message
182
+
into the database:
183
+
184
+
.. literalinclude:: /includes/csfle.cpp
185
+
:language: cpp
186
+
:copyable: true
187
+
:start-after: // start-explicit-encrypt
188
+
:end-before: // end-explicit-encrypt
189
+
190
+
To view a full example that configures explicit encryption,
191
+
see the :github:`Explicit Encryption <mongodb/mongo-cxx-driver/blob/master/examples/mongocxx/explicit_encryption.cpp>`
192
+
example in the driver source code.
193
+
194
+
Explicit Encryption with Automatic Decryption
195
+
`````````````````````````````````````````````
196
+
197
+
You can configure explicit encryption and automatic decryption,
198
+
which is supported for all users. To configure automatic decryption
199
+
without automatic encryption, create an ``options::auto_encryption``
200
+
instance and set its ``bypass_auto_encryption`` field to ``true``.
201
+
Then, apply these options to your client.
202
+
203
+
The following example creates an ``options::auto_encryption`` instance
204
+
to configure explicit encryption with automatic decryption,
205
+
then passes this options instance to the ``auto_encryption_opts`` field
206
+
of an ``options::client``. This creates a client configured to
207
+
use automatic decryption:
208
+
209
+
.. literalinclude:: /includes/csfle.cpp
210
+
:language: cpp
211
+
:copyable: true
212
+
:start-after: // start-auto-decrypt
213
+
:end-before: // end-auto-decrypt
214
+
215
+
To view a full example that configures explicit encryption
216
+
with automatic decryption, see the :github:`Explicit Encryption Auto Decryption
0 commit comments