<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mongodb-driver-clientencryption.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-clientencryption.encrypt.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::encrypt',
    2 => 'Encrypt a value',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-clientencryption.php',
    1 => 'MongoDB\\Driver\\ClientEncryption',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-clientencryption.deletekey.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::deleteKey',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-clientencryption.encryptexpression.php',
    1 => 'MongoDB\\Driver\\ClientEncryption::encryptExpression',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/clientencryption/encrypt.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-clientencryption.encrypt" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\ClientEncryption::encrypt</h1>
  <p class="verinfo">(mongodb &gt;=1.7.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\ClientEncryption::encrypt</span> &mdash; <span class="dc-title">Encrypt a value</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-clientencryption.encrypt-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\ClientEncryption::encrypt</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="class.mongodb-bson-binary.php" class="type MongoDB\BSON\Binary">MongoDB\BSON\Binary</a></span></div>

  <p class="para rdfs-comment">
   Encrypts the value.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-clientencryption.encrypt-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">value</code></dt>
    <dd>
     <p class="para">
      The value to be encrypted. Any value that can be inserted into MongoDB can
      be encrypted using this method.
     </p>
    </dd>
   
   
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="para">
      <table class="doctable table">
       <caption><strong>Параметри шифрування</strong></caption>
       
        <thead>
         <tr>
          <th>Параметр</th>
          <th>Тип</th>
          <th>Опис</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>algorithm</td>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Алгоритм, що потрібно використати. Цей параметр обов&#039;язковий.
            Дозволено вказувати одну з
            <a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants" class="link">констант
            ClientEncryption</a>:
           </p>
           <ul class="simplelist">
            <li><strong><code>MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC</code></strong></li>
            <li><strong><code>MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM</code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-indexed">MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED</a></code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-unindexed">MongoDB\Driver\ClientEncryption::ALGORITHM_UNINDEXED</a></code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-range">MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE</a></code></strong></li>
           </ul>
          </td>
         </tr>

         <tr>
          <td>contentionFactor</td>
          <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
          <td>
           <p class="para">
            Фактор конкуренції виконання запитів із індексованим зашифрованим
            корисним навантаженням.
           </p>
           <p class="para">
            Цей параметр застосовується тільки, якщо параметр
            <code class="literal">algorithm</code> має значення
            <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-indexed">MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED</a></code></strong>
            або
            <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-range">MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE</a></code></strong>.
           </p>
          </td>
         </tr>

         <tr>
          <td>keyAltName</td>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Визначає назву документа колекції з сховищем ключів за
            <code class="literal">keyAltName</code>. Цей параметр є взаємовиключним з
            <code class="literal">keyId</code>, тож потрібен саме один з них.
           </p>
          </td>
         </tr>

         <tr>
          <td>keyId</td>
          <td><span class="classname"><a href="class.mongodb-bson-binary.php" class="classname">MongoDB\BSON\Binary</a></span></td>
          <td>
           <p class="para">
            Визначає ключ даних за <code class="literal">_id</code>. Значенням має бути
            UUID (двійковий підтип 4). Цей параметр є взаємовиключним з
            <code class="literal">keyAltName</code>, тож потрібен саме один з них.
           </p>
          </td>
         </tr>

         <tr>
          <td>queryType</td>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>
           <p class="para">
            Тип запиту з індексованим зашифорваним корисним навантаженням.
            Дозволено вказувати одну з
            <a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants" class="link">констант
            ClientEncryption</a>:
           </p>
           <ul class="simplelist">
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.query-type-equality">MongoDB\Driver\ClientEncryption::QUERY_TYPE_EQUALITY</a></code></strong></li>
            <li><strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.query-type-range">MongoDB\Driver\ClientEncryption::QUERY_TYPE_RANGE</a></code></strong></li>
           </ul>
           <p class="para">
            Цей параметр застововується тільки, якщо параметр
            <code class="literal">algorithm</code> має значення
            <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-indexed">MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED</a></code></strong>
            або <strong><code><a href="class.mongodb-driver-clientencryption.php#mongodb-driver-clientencryption.constants.algorithm-range">MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE</a></code></strong>.
           </p>
          </td>
         </tr>

         <tr>
          <td>rangeOpts</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <p class="para">
            Параметри індексу для запиту зашифрованого поля, яке підтримує
            &quot;range&quot;-запити. Параметри, що нижче, мають відповідати набору
            значень в <code class="literal">encryptedFields</code> обраної колекції. Для
            полів з BSON-типами &quot;double&quot;, &quot;decimal128&quot;, параметри
            <code class="literal">min</code>, <code class="literal">max</code> та
            <code class="literal">precision</code> потрібно задавати всі або жодного.
           </p>
           <p class="para">
            <table class="doctable table">
             <caption><strong>Параметри індексу діапазону</strong></caption>
             
              <thead>
               <tr>
                <th>Параметр</th>
                <th>Тип</th>
                <th>Опис</th>
               </tr>

              </thead>

              <tbody class="tbody">
               <tr>
                <td>min</td>
                <td><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></td>
                <td>
                 Нижня межа діапазону, яка має BSON-значення. Параметр
                 обов&#039;язковий, якщо задано <code class="literal">precision</code>.
                </td>
               </tr>

               <tr>
                <td>max</td>
                <td><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></td>
                <td>
                 Верхня межа діапазону, яка має BSON-значення. Параметр
                 обов&#039;язковий, якщо задано <code class="literal">precision</code>.
                </td>
               </tr>

               <tr>
                <td>sparsity</td>
                <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
                <td>Обов&#039;язковий. Додатнє ціле 64-бітне число.</td>
               </tr>

               <tr>
                <td>precision</td>
                <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
                <td>
                 Необов&#039;язковий. Додатнє ціле 32-бітне число, що вказує
                 точність явного шифрування. Можна задавати тільки для полів з
                 BSON-типами &quot;double&quot; або &quot;decimal128&quot;.
                </td>
               </tr>

               <tr>
                <td>trimFactor</td>
                <td><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></td>
                <td>Необов&#039;язковий. Додатнє ціле 32-бітне число.</td>
               </tr>

              </tbody>
             
            </table>

           </p>
          </td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>
   

  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-clientencryption.encrypt-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns the encrypted value as
   <span class="classname"><a href="class.mongodb-bson-binary.php" class="classname">MongoDB\BSON\Binary</a></span> object with subtype 6.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-clientencryption.encrypt-errors">
  <h3 class="title">Помилки/виключення</h3>
  <ul class="simplelist">
   <li>У разі помилки обробки параметрів
викидається
<span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span>.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-encryptionexception.php" class="classname">MongoDB\Driver\Exception\EncryptionException</a></span> if an error occurs while encrypting the value</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-clientencryption.encrypt-changelog">
  <h3 class="title">Журнал змін</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Версія</th>
       <th>Опис</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>PECL mongodb 1.20.0</td>
       <td>
        Added the <code class="literal">&quot;trimFactor&quot;</code> range option. The
        <code class="literal">&quot;sparsity&quot;</code> range option is now optional.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.16.0</td>
       <td>
        Added the <code class="literal">&quot;rangeOpts&quot;</code> option.
       </td>
      </tr>

      <tr>
       <td>PECL mongodb 1.14.0</td>
       <td>
        Added the <code class="literal">&quot;contentionFactor&quot;</code> and
        <code class="literal">&quot;queryType&quot;</code> options.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-clientencryption.encrypt-seealso">
  <h3 class="title">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="mongodb-driver-clientencryption.decrypt.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\ClientEncryption::decrypt()</a> - Decrypt a value</span></li>
   <li><span class="function"><a href="mongodb-driver-clientencryption.encryptexpression.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\ClientEncryption::encryptExpression()</a> - Encrypts a match or aggregate expression</span></li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>