<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.password.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.password-verify.php',
    1 => 'password_verify',
    2 => 'Verifies that a password matches a hash',
  ),
  'up' => 
  array (
    0 => 'ref.password.php',
    1 => 'Функції Хешування Пароля',
  ),
  'prev' => 
  array (
    0 => 'function.password-needs-rehash.php',
    1 => 'password_needs_rehash',
  ),
  'next' => 
  array (
    0 => 'book.rnp.php',
    1 => 'Rnp',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/password/functions/password-verify.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.password-verify" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">password_verify</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">password_verify</span> &mdash; <span class="dc-title">Verifies that a password matches a hash</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.password-verify-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>password_verify</strong></span>(<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">$password</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$hash</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Verifies that the given hash matches the given password.
   <span class="function"><strong>password_verify()</strong></span> is compatible with <span class="function"><a href="function.crypt.php" class="function">crypt()</a></span>.
   Therefore, password hashes created by <span class="function"><a href="function.crypt.php" class="function">crypt()</a></span> can be used with
   <span class="function"><strong>password_verify()</strong></span>.
  </p>
  <p class="para">
   Note that <span class="function"><a href="function.password-hash.php" class="function">password_hash()</a></span> returns the algorithm, cost and salt 
   as part of the returned hash. Therefore, all information that&#039;s needed to verify
   the hash is included in it. This allows the verify function to verify the hash
   without needing separate storage for the salt or algorithm information.
  </p>
  <p class="para">
   This function is safe against timing attacks.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.password-verify-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">password</code></dt>
    <dd>
     <p class="para">
      Користувацький пароль.
     </p>
    </dd>
   
   
    <dt><code class="parameter">hash</code></dt>
    <dd>
     <p class="para">
      Геш, створений функцією <span class="function"><a href="function.password-hash.php" class="function">password_hash()</a></span>.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.password-verify-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if the password and hash match, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.password-verify-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>password_verify()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     This is a simplified example; it is recommended to rehash a correct password
     if necessary; see <span class="function"><a href="function.password-needs-rehash.php" class="function">password_needs_rehash()</a></span> for an example.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// See the password_hash() example to see where this came from.<br /></span><span style="color: #0000BB">$hash </span><span style="color: #007700">= </span><span style="color: #DD0000">'$2y$12$4Umg0rCJwMswRw/l.SwHvuQV01coP0eWmGzd61QH2RvAOMANUBGC.'</span><span style="color: #007700">;<br /><br />if (</span><span style="color: #0000BB">password_verify</span><span style="color: #007700">(</span><span style="color: #DD0000">'rasmuslerdorf'</span><span style="color: #007700">, </span><span style="color: #0000BB">$hash</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">'Password is valid!'</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">'Invalid password.'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Поданий вище приклад
виведе:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Password is valid!</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.password-verify-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.password-needs-rehash.php" class="function" rel="rdfs-seeAlso">password_needs_rehash()</a> - Checks if the given hash matches the given options</span></li>
    <li><span class="function"><a href="function.password-hash.php" class="function" rel="rdfs-seeAlso">password_hash()</a> - Creates a password hash</span></li>
    <li><span class="function"><a href="function.sodium-crypto-pwhash-str-verify.php" class="function" rel="rdfs-seeAlso">sodium_crypto_pwhash_str_verify()</a> - Verifies that a password matches a hash</span></li>
   </ul>
  </p>
 </div>


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