<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.openssl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.openssl-decrypt.php',
    1 => 'openssl_decrypt',
    2 => 'Расшифровывает данные',
  ),
  'up' => 
  array (
    0 => 'ref.openssl.php',
    1 => 'Функции OpenSSL',
  ),
  'prev' => 
  array (
    0 => 'function.openssl-csr-sign.php',
    1 => 'openssl_csr_sign',
  ),
  'next' => 
  array (
    0 => 'function.openssl-dh-compute-key.php',
    1 => 'openssl_dh_compute_key',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/openssl/functions/openssl-decrypt.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.openssl-decrypt" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_decrypt</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">openssl_decrypt</span> &mdash; <span class="dc-title">Расшифровывает данные</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-decrypt-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_decrypt</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$cipher_algo</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="attribute"><a href="class.sensitiveparameter.php">#[\SensitiveParameter]</a> </span><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$passphrase</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$iv</code><span class="initializer"> = &quot;&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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.string.php" class="type string">string</a></span></span> <code class="parameter">$tag</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$aad</code><span class="initializer"> = &quot;&quot;</span></span><br>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Функция берёт необработанную или кодированную в base64 строку и расшифровывает её
   заданным методом и кодовой фразой.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-decrypt-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       Данные для расшифровки.
      </p>
     </dd>
    
    
     <dt><code class="parameter">cipher_algo</code></dt>
     <dd>
      <p class="para">
       Метод шифрования. Список доступных методов возвращает функция
       <span class="function"><a href="function.openssl-get-cipher-methods.php" class="function">openssl_get_cipher_methods()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">passphrase</code></dt>
     <dd>
      <p class="para">
       Кодовая фраза. Если кодовая фраза короче, чем ожидалось, она заполняется символами <code class="literal">NUL</code>;
       если кодовая фраза длиннее, чем ожидалось, она усекается.
      </p>
      <div class="caution"><strong class="caution">Предостережение</strong>
       <p class="simpara">
        Для параметра <code class="parameter">passphrase</code> не используется функция извлечения ключа,
        как можно предположить из его названия.
        Единственная операция, которая используется, – это заполнение символами
        <code class="literal">NUL</code> или усечение, если длина отличается от ожидаемой.
       </p>
      </div>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">options</code> можно задать одной из констант:
       <strong><code><a href="openssl.constants.other.php#constant.openssl-raw-data">OPENSSL_RAW_DATA</a></code></strong>,
       <strong><code><a href="openssl.constants.other.php#constant.openssl-zero-padding">OPENSSL_ZERO_PADDING</a></code></strong>
       или <strong><code><a href="openssl.constants.other.php#constant.openssl-dont-zero-pad-key">OPENSSL_DONT_ZERO_PAD_KEY</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">iv</code></dt>
     <dd>
      <p class="para">
       Ненулевой (non-<strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>) инициализирующий вектор.
       Если IV короче, чем ожидалось, он заполняется символами <code class="literal">NUL</code>
       и выдаётся предупреждение;
       если кодовая фраза длиннее, чем ожидалось, он усекается и выдаётся предупреждение.
      </p>
     </dd>
    
    
     <dt><code class="parameter">tag</code></dt>
     <dd>
      <p class="para">
       Тег аутентификации в режиме шифрования AEAD. Если он некорректен, то
       аутентификация завершится неудачей и функция вернёт <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </p>
      <div class="caution"><strong class="caution">Предостережение</strong>
       <p class="simpara">
        Длина <code class="parameter">tag</code> не проверяется функцией.
        Вызывающая сторона несёт ответственность за то, чтобы длина тега
        соответствовала длине тега, полученного при вызове <span class="function"><a href="function.openssl-encrypt.php" class="function">openssl_encrypt()</a></span>.
        В противном случае дешифрование может быть успешным, если данный тег
        совпадает только с началом правильного тега.
       </p>
      </div>
     </dd>
    
    
     <dt><code class="parameter">aad</code></dt>
     <dd>
      <p class="para">
       Дополнительные аутентифицированные данные.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-decrypt-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="para">
   Функция возвращает расшифрованную строку или <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>, если возникла ошибка.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.openssl-decrypt-errors">
  <h3 class="title">Ошибки</h3>
  <p class="para">
   Функция выдаёт ошибку уровня <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>, если в параметр
   <code class="parameter">cipher_algo</code> передали неизвестный алгоритм шифрования.
  </p>
  <p class="para">
   Функция выдаёт ошибку уровня <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>, если в параметр
   <code class="parameter">iv</code> передали пустое значение.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.openssl-decrypt-changelog">
  <h3 class="title">Список изменений</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версия</th>
      <th>Описание</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.1.0</td>
      <td>
       Параметр <code class="parameter">tag</code> теперь принимает значение null.
      </td>
     </tr>

     <tr>
      <td>7.1.0</td>
      <td>Добавили параметры <code class="parameter">tag</code> и <code class="parameter">aad</code>.</td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-decrypt-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.openssl-encrypt.php" class="function" rel="rdfs-seeAlso">openssl_encrypt()</a> - Шифрует данные</span></li>
   </ul>
  </p>
 </div>


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