<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.sodium.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.sodium-crypto-pwhash-scryptsalsa208sha256.php',
    1 => 'sodium_crypto_pwhash_scryptsalsa208sha256',
    2 => 'Derives a key from a password, using scrypt',
  ),
  'up' => 
  array (
    0 => 'ref.sodium.php',
    1 => 'Sodium 函数',
  ),
  'prev' => 
  array (
    0 => 'function.sodium-crypto-pwhash.php',
    1 => 'sodium_crypto_pwhash',
  ),
  'next' => 
  array (
    0 => 'function.sodium-crypto-pwhash-scryptsalsa208sha256-str.php',
    1 => 'sodium_crypto_pwhash_scryptsalsa208sha256_str',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/sodium/functions/sodium-crypto-pwhash-scryptsalsa208sha256.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.sodium-crypto-pwhash-scryptsalsa208sha256" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sodium_crypto_pwhash_scryptsalsa208sha256</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">sodium_crypto_pwhash_scryptsalsa208sha256</span> &mdash; <span class="dc-title">Derives a key from a password, using scrypt</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.sodium-crypto-pwhash-scryptsalsa208sha256-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>sodium_crypto_pwhash_scryptsalsa208sha256</strong></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">$length</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">$password</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">$salt</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">$opslimit</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">$memlimit</code></span><br>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="simpara">
   This is the scrypt counterpart to <span class="function"><a href="function.sodium-crypto-pwhash.php" class="function">sodium_crypto_pwhash()</a></span>.
  </p>
  <p class="simpara">
   A common reason to use this particular function is to derive the seeds for cryptographic keys from a password and salt,
   and then use these seeds to generate the actual keys needed for some purpose (e.g. <span class="function"><a href="function.sodium-crypto-sign-detached.php" class="function">sodium_crypto_sign_detached()</a></span>).
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.sodium-crypto-pwhash-scryptsalsa208sha256-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">length</code></dt>
    <dd>
     <span class="simpara">
      The length of the password hash to generate, in bytes.
     </span>
    </dd>
   
   
    <dt><code class="parameter">password</code></dt>
    <dd>
     <span class="simpara">
      The password to generate a hash for.
     </span>
    </dd>
   
   
    <dt><code class="parameter">salt</code></dt>
    <dd>
     <span class="simpara">
      A salt to add to the password before hashing. The salt should be unpredictable, ideally generated from a good random number source such as <span class="function"><a href="function.random-bytes.php" class="function">random_bytes()</a></span>, and have a length of at least <strong><code><a href="sodium.constants.php#constant.sodium-crypto-pwhash-scryptsalsa208sha256-saltbytes">SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES</a></code></strong> bytes.
     </span>
    </dd>
   
   
    <dt><code class="parameter">opslimit</code></dt>
    <dd>
     <span class="simpara">
      Represents a maximum amount of computations to perform. Raising this number will make the function require more CPU cycles to compute a key. There are some constants available to set the operations limit to appropriate values depending on intended use, in order of strength: <strong><code><a href="sodium.constants.php#constant.sodium-crypto-pwhash-scryptsalsa208sha256-opslimit-interactive">SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE</a></code></strong> and <strong><code><a href="sodium.constants.php#constant.sodium-crypto-pwhash-scryptsalsa208sha256-opslimit-sensitive">SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE</a></code></strong>.
     </span>
    </dd>
   
   
    <dt><code class="parameter">memlimit</code></dt>
    <dd>
     <span class="simpara">
      The maximum amount of RAM that the function will use, in bytes. There are constants to help you choose an appropriate value, in order of size: <strong><code><a href="sodium.constants.php#constant.sodium-crypto-pwhash-scryptsalsa208sha256-memlimit-interactive">SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE</a></code></strong> and <strong><code><a href="sodium.constants.php#constant.sodium-crypto-pwhash-scryptsalsa208sha256-memlimit-sensitive">SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE</a></code></strong>. Typically these should be paired with the matching <code class="parameter">opslimit</code> values.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sodium-crypto-pwhash-scryptsalsa208sha256-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   A string of bytes of the desired length.
  </p>
 </div>



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