<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Client-Side Field Level Encryption Methods
  <a class="headerlink leafygreen-ui-1kepx47" href="#client-side-field-level-encryption-methods" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="client-side-field-level-encryption-methods">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-15mdk4" role="note">
  <h2 class="leafygreen-ui-6n7b7d">
   Note
  </h2>
  <div class="leafygreen-ui-9mycqc">
   <p class="leafygreen-ui-1kp3ins">
    For details on a specific method, including syntax and examples,
click on the link to the method's reference page.
   </p>
  </div>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  The
  <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self">
   <span>
    <code class="leafygreen-ui-1l06pbn">
     mongosh
    </code>
   </span>
  </a>
  client-side field level encryption methods
require a database connection with client-side field level encryption
enabled. If the current database connection was not initiated with
client-side field level encryption enabled, either:
 </p>
 <ul class="leafygreen-ui-rioki0">
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    Use the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo">
     <code class="leafygreen-ui-1l06pbn">
      Mongo()
     </code>
    </a>
    constructor from the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       mongosh
      </code>
     </span>
    </a>
    to establish a connection with the required client-side field
level encryption options. The
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/Mongo/#mongodb-method-Mongo">
     <code class="leafygreen-ui-1l06pbn">
      Mongo()
     </code>
    </a>
    method supports the
following Key Management Service (KMS) providers for Customer
Master Key (CMK) management:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws">
       Amazon Web Services KMS
      </a>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-azure">
       Azure Key Vault
      </a>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-gcp">
       Google Cloud Platform KMS
      </a>
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-local">
       Locally Managed Key
      </a>
     </p>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    <em>
     or
    </em>
   </p>
  </li>
  <li class="leafygreen-ui-d7p7b6">
   <p class="leafygreen-ui-1kp3ins">
    Use the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       mongosh
      </code>
     </span>
    </a>
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/reference/options/#std-label-mongosh-client-side-field-level-encryption-options" target="_self">
     <span>
      command line options
     </span>
    </a>
    to establish a
connection with the required options. The command line options only
support the
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/fundamentals/kms-providers/#std-label-qe-fundamentals-kms-providers-aws">
     Amazon Web Services KMS
    </a>
    provider for CMK management.
   </p>
  </li>
 </ul>
 <p class="leafygreen-ui-1kp3ins">
  The following methods are for
  <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/mongodb-shell/#mongodb-binary-bin.mongosh" target="_self">
   <span>
    <code class="leafygreen-ui-1l06pbn">
     mongosh
    </code>
   </span>
  </a>
  <em>
   only
  </em>
  . For instructions on implementing client-side field level
encryption using a MongoDB driver, defer to the driver documentation. See
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/queryable-encryption/reference/compatibility/#std-label-csfle-driver-compatibility">
   Client-Side Field Level Encryption Driver Compatibility
  </a>
  for a complete list of drivers with support
for client-side field level encryption.
 </p>
 <div class="leafygreen-ui-skkc39" tabindex="0">
  <table class="leafygreen-ui-hr8lsv">
   <colgroup>
    <col style="width:30%"/>
    <col style="width:70%"/>
   </colgroup>
   <thead class="leafygreen-ui-a9ho40">
    <tr data-testid="leafygreen-ui-header-row">
     <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
      <div class="leafygreen-ui-ui0te9">
       <div>
        Name
       </div>
      </div>
     </th>
     <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
      <div class="leafygreen-ui-ui0te9">
       <div>
        Description
       </div>
      </div>
     </th>
    </tr>
   </thead>
   <tbody>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/getKeyVault/#mongodb-method-getKeyVault">
         <code class="leafygreen-ui-1l06pbn">
          getKeyVault()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Returns the key vault object for the current MongoDB connection.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.createKey/#mongodb-method-KeyVault.createKey">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.createKey()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Creates a data encryption key for use with client-side field level encryption.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.deleteKey/#mongodb-method-KeyVault.deleteKey">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.deleteKey()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Deletes the specified data encryption key from the key vault.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.getKey/#mongodb-method-KeyVault.getKey">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.getKey()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Retreives the specified data encryption key from the key vault.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.getKeys/#mongodb-method-KeyVault.getKeys">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.getKeys()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Retrieves all keys in the key vault.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.addKeyAlternateName/#mongodb-method-KeyVault.addKeyAlternateName">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.addKeyAlternateName()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Associates a key alternative name to the specified data encryption key.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.removeKeyAlternateName/#mongodb-method-KeyVault.removeKeyAlternateName">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.removeKeyAlternateName()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Removes a key alternative name from the specified data encryption key.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.rewrapManyDataKey/#mongodb-method-KeyVault.rewrapManyDataKey">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.rewrapManyDataKey()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Decrypts multiple data keys and re-encrypts them with a new master key.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/KeyVault.getKeyByAltName/#mongodb-method-KeyVault.getKeyByAltName">
         <code class="leafygreen-ui-1l06pbn">
          KeyVault.getKeyByAltName()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Retrieves keys with the specified key alternative name.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/getClientEncryption/#mongodb-method-getClientEncryption">
         <code class="leafygreen-ui-1l06pbn">
          getClientEncryption()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Returns the client encryption object for supporting explicit encryption/decryption of fields.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/ClientEncryption.createEncryptedCollection/#mongodb-method-ClientEncryption.createEncryptedCollection">
         <code class="leafygreen-ui-1l06pbn">
          ClientEncryption.createEncryptedCollection()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Creates a collection with encrypted fields.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/ClientEncryption.encrypt/#mongodb-method-ClientEncryption.encrypt">
         <code class="leafygreen-ui-1l06pbn">
          ClientEncryption.encrypt()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Encrypts a field using a specified data encryption key and encryption algorithm.
       </div>
      </div>
     </td>
    </tr>
    <tr class="leafygreen-ui-15dvrnp">
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/ClientEncryption.decrypt/#mongodb-method-ClientEncryption.decrypt">
         <code class="leafygreen-ui-1l06pbn">
          ClientEncryption.decrypt()
         </code>
        </a>
       </div>
      </div>
     </td>
     <td class="leafygreen-ui-1drjk7h">
      <div class="leafygreen-ui-1n4j8xf">
       <div>
        Decrypts a field using the associated data encryption key and encryption algorithm.
       </div>
      </div>
     </td>
    </tr>
   </tbody>
  </table>
 </div>
</section>
