<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.password.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'password.constants.php',
    1 => 'Predefined Constants',
    2 => 'Predefined Constants',
  ),
  'up' => 
  array (
    0 => 'book.password.php',
    1 => 'Password Hashing',
  ),
  'prev' => 
  array (
    0 => 'password.installation.php',
    1 => 'Installation',
  ),
  'next' => 
  array (
    0 => 'ref.password.php',
    1 => 'Password Hashing Functions',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/password/constants.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="password.constants" class="appendix">
 <h1 class="title">Predefined Constants</h1>

 <p class="simpara">
The constants below are always available as part of the PHP core.
</p>

 <p class="para">
  <dl>
   
    <dt id="constant.password-bcrypt">
     <strong><code><a href="password.constants.php#constant.password-bcrypt">PASSWORD_BCRYPT</a></code></strong>
     (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)
    </dt>
    <dd>
     <p class="para">
      <strong><code><a href="password.constants.php#constant.password-bcrypt">PASSWORD_BCRYPT</a></code></strong> is used to create new password
      hashes using the <strong><code><a href="string.constants.php#constant.crypt-blowfish">CRYPT_BLOWFISH</a></code></strong> algorithm.
     </p>
     <p class="para">
      This will always result in a hash using the &quot;$2y$&quot; crypt format,
      which is always 60 characters wide.
     </p>
     <p class="para">
      Supported Options:
     </p>
     <ul class="itemizedlist">
      <li class="listitem">
       <p class="para">
        <code class="literal">salt</code> (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>) - to manually provide a salt to use when hashing the password.
        Note that this will override and prevent a salt from being automatically generated.
       </p>
       <p class="para">
        If omitted, a random salt will be generated by <span class="function"><a href="function.password-hash.php" class="function">password_hash()</a></span> for
        each password hashed. This is the intended mode of operation
        and as of PHP 7.0.0 the salt option has been deprecated.
       </p>
      </li>
      <li class="listitem">
       <p class="para">
        <code class="literal">cost</code> (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>) - which denotes the algorithmic cost that
        should be used. Examples of these values can be found on the <span class="function"><a href="function.crypt.php" class="function">crypt()</a></span>
        page.
       </p>
       <p class="para">
        If omitted, a default value of <code class="literal">12</code> will be used. This is a good
        baseline cost, but you may want to consider increasing it depending on your hardware.
       </p>
      </li>
     </ul>
    </dd>
   
   
    <dt id="constant.password-bcrypt-default-cost">
     <strong><code><a href="password.constants.php#constant.password-bcrypt-default-cost">PASSWORD_BCRYPT_DEFAULT_COST</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
    </dt>
    <dd>
     <p class="para">
     </p>
     <p class="para">
     </p>
    </dd>
   
   
    <dt id="constant.password-argon2i">
     <strong><code><a href="password.constants.php#constant.password-argon2i">PASSWORD_ARGON2I</a></code></strong>
     (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)
    </dt>
    <dd>
     <p class="para">
      <strong><code><a href="password.constants.php#constant.password-argon2i">PASSWORD_ARGON2I</a></code></strong> is used to create new password
      hashes using the Argon2i algorithm.
     </p>
     <p class="para">
      Supported Options:
     </p>
     <ul class="itemizedlist">
      <li class="listitem">
       <p class="para">
        <code class="literal">memory_cost</code> (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>) - Maximum memory (in kibibytes) that may
        be used to compute the Argon2 hash. Defaults to <strong><code><a href="password.constants.php#constant.password-argon2-default-memory-cost">PASSWORD_ARGON2_DEFAULT_MEMORY_COST</a></code></strong>.
       </p>
      </li>
      <li class="listitem">
       <p class="para">
        <code class="literal">time_cost</code> (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>) - Maximum amount of time it may
        take to compute the Argon2 hash. Defaults to <strong><code><a href="password.constants.php#constant.password-argon2-default-time-cost">PASSWORD_ARGON2_DEFAULT_TIME_COST</a></code></strong>.
       </p>
      </li>
      <li class="listitem">
       <p class="para">
        <code class="literal">threads</code> (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>) - Number of threads to use for computing
        the Argon2 hash. Defaults to <strong><code><a href="password.constants.php#constant.password-argon2-default-threads">PASSWORD_ARGON2_DEFAULT_THREADS</a></code></strong>.
        Only available with libargon2, not with libsodium implementation.
       </p>
      </li>
     </ul>
     <p class="para">
      Available as of PHP 7.2.0.
     </p>
    </dd>
   
   
    <dt id="constant.password-argon2id">
     <strong><code><a href="password.constants.php#constant.password-argon2id">PASSWORD_ARGON2ID</a></code></strong>
     (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)
    </dt>
    <dd>
     <p class="para">
      <strong><code><a href="password.constants.php#constant.password-argon2id">PASSWORD_ARGON2ID</a></code></strong> is used to create new password
      hashes using the Argon2id algorithm. It supports the same options as
      <a href="password.constants.php#constant.password-argon2i" class="link"><strong><code><a href="password.constants.php#constant.password-argon2i">PASSWORD_ARGON2I</a></code></strong></a>.
     </p>
     <p class="para">
      Available as of PHP 7.3.0.
     </p>
    </dd>
   
   
    <dt id="constant.password-argon2-default-memory-cost">
     <strong><code><a href="password.constants.php#constant.password-argon2-default-memory-cost">PASSWORD_ARGON2_DEFAULT_MEMORY_COST</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
    </dt>
    <dd>
     <p class="para">
      Default amount of memory in bytes that will be used while trying to
      compute a hash.
     </p>
     <p class="para">
      Available as of PHP 7.2.0.
     </p>
    </dd>
   
   
    <dt id="constant.password-argon2-default-time-cost">
     <strong><code><a href="password.constants.php#constant.password-argon2-default-time-cost">PASSWORD_ARGON2_DEFAULT_TIME_COST</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
    </dt>
    <dd>
     <p class="para">
      Default amount of time that will be spent trying to compute a hash.
     </p>
     <p class="para">
      Available as of PHP 7.2.0.
     </p>
    </dd>
   
   
    <dt id="constant.password-argon2-default-threads">
     <strong><code><a href="password.constants.php#constant.password-argon2-default-threads">PASSWORD_ARGON2_DEFAULT_THREADS</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
    </dt>
    <dd>
     <p class="para">
      Default number of threads that Argon2lib will use.
      Not available with libsodium implementation.
     </p>
     <p class="para">
      Available as of PHP 7.2.0.
     </p>
    </dd>
   
   
    <dt id="constant.password-argon2-provider">
     <strong><code><a href="password.constants.php#constant.password-argon2-provider">PASSWORD_ARGON2_PROVIDER</a></code></strong>
     (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)
    </dt>
    <dd>
     <p class="para">
     </p>
     <p class="para">
      Available as of PHP 7.4.0.
     </p>
    </dd>
   
   
    <dt id="constant.password-default">
     <strong><code><a href="password.constants.php#constant.password-default">PASSWORD_DEFAULT</a></code></strong>
     (<span class="type"><a href="language.types.string.php" class="type string">string</a></span>)
    </dt>
    <dd>
     <p class="para">
      The default algorithm to use for hashing if no algorithm is provided.
      This may change in newer PHP releases when newer, stronger hashing
      algorithms are supported.
     </p>
     <p class="para">
      It is worth noting that over time this constant can change.
      It is thus important to be aware that the length of the resulting
      hash can change.
      Therefore, when using <strong><code><a href="password.constants.php#constant.password-default">PASSWORD_DEFAULT</a></code></strong> the resulting
      hash must be stored in a way that can store arbitrary hashes,
      the recommended width is <code class="literal">255</code> bytes.
     </p>
     <span class="simpara">
      Currently is an alias for <strong><code><a href="password.constants.php#constant.password-bcrypt">PASSWORD_BCRYPT</a></code></strong>.
     </span>
    </dd>
   
  </dl>
 </p>

 <p class="formalpara">
  <h5 class="title">Changelog</h5>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.4.0</td>
       <td>
        The values of the password algo IDs (<strong><code><a href="password.constants.php#constant.password-bcrypt">PASSWORD_BCRYPT</a></code></strong>, <strong><code><a href="password.constants.php#constant.password-argon2i">PASSWORD_ARGON2I</a></code></strong>,
        <strong><code><a href="password.constants.php#constant.password-argon2id">PASSWORD_ARGON2ID</a></code></strong> and <strong><code><a href="password.constants.php#constant.password-default">PASSWORD_DEFAULT</a></code></strong>) are now <span class="type"><a href="language.types.string.php" class="type string">string</a></span>s.
        Previously, they have been <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>s.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </p>

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