Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3368

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Initialize an incremental hashing context</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.hash-hmac.html">hash_hmac</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.hash-pbkdf2.html">hash_pbkdf2</a></div>
 <div class="up"><a href="ref.hash.html">Hash Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.hash-init" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">hash_init</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PECL hash &gt;= 1.1)</p><p class="refpurpose"><span class="refname">hash_init</span> &mdash; <span class="dc-title">Initialize an incremental hashing context</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.hash-init-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">resource</span> <span class="methodname"><strong>hash_init</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$algo</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = 0</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$key</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]] )</div>


 </div>

 <div class="refsect1 parameters" id="refsect1-function.hash-init-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">algo</code></em></span>
     <dd>

      <p class="para">
       Name of selected hashing algorithm (i.e. &quot;md5&quot;, &quot;sha256&quot;, &quot;haval160,4&quot;, etc..). For a list of supported algorithms see  <span class="function"><a href="function.hash-algos.html" class="function">hash_algos()</a></span>.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">options</code></em></span>
     <dd>

      <p class="para">
       Optional settings for hash generation, currently supports only one option:
       <strong><code>HASH_HMAC</code></strong>.  When specified, the <em><code class="parameter">key</code></em>
       <em class="emphasis">must</em> be specified.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">key</code></em></span>
     <dd>

      <p class="para">
       When <strong><code>HASH_HMAC</code></strong> is specified for <em><code class="parameter">options</code></em>,
       a shared secret key to be used with the HMAC hashing method must be supplied in this
       parameter.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.hash-init-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a Hashing Context resource for use with  <span class="function"><a href="function.hash-update.html" class="function">hash_update()</a></span>,
    <span class="function"><a href="function.hash-update-stream.html" class="function">hash_update_stream()</a></span>,  <span class="function"><a href="function.hash-update-file.html" class="function">hash_update_file()</a></span>,
   and  <span class="function"><a href="function.hash-final.html" class="function">hash_final()</a></span>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.hash-init-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-834">
    <p><strong>Example #1 Incremental hashing example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$ctx&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">hash_init</span><span style="color: #007700">(</span><span style="color: #DD0000">'md5'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">hash_update</span><span style="color: #007700">(</span><span style="color: #0000BB">$ctx</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'The&nbsp;quick&nbsp;brown&nbsp;fox&nbsp;'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">hash_update</span><span style="color: #007700">(</span><span style="color: #0000BB">$ctx</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'jumped&nbsp;over&nbsp;the&nbsp;lazy&nbsp;dog.'</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">hash_final</span><span style="color: #007700">(</span><span style="color: #0000BB">$ctx</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
5c6ffbdd40d9556b73a21e63c3e0e904
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.hash-init-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.hash.html" class="function" rel="rdfs-seeAlso">hash()</a> - Generate a hash value (message digest)</span></li>
    <li class="member"> <span class="function"><a href="function.hash-algos.html" class="function" rel="rdfs-seeAlso">hash_algos()</a> - Return a list of registered hashing algorithms</span></li>
    <li class="member"> <span class="function"><a href="function.hash-file.html" class="function" rel="rdfs-seeAlso">hash_file()</a> - Generate a hash value using the contents of a given file</span></li>
    <li class="member"> <span class="function"><a href="function.hash-hmac.html" class="function" rel="rdfs-seeAlso">hash_hmac()</a> - Generate a keyed hash value using the HMAC method</span></li>
    <li class="member"> <span class="function"><a href="function.hash-hmac-file.html" class="function" rel="rdfs-seeAlso">hash_hmac_file()</a> - Generate a keyed hash value using the HMAC method and the contents of a given file</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.hash-hmac.html">hash_hmac</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.hash-pbkdf2.html">hash_pbkdf2</a></div>
 <div class="up"><a href="ref.hash.html">Hash Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>