Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 3911

php-manual-en-7.2.11-1.mga7.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>Generate a keyed hash value using the HMAC method and the contents of a given file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.hash-hmac-algos.html">hash_hmac_algos</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.hash-hmac.html">hash_hmac</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-hmac-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">hash_hmac_file</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PHP 7, PECL hash &gt;= 1.1)</p><p class="refpurpose"><span class="refname">hash_hmac_file</span> &mdash; <span class="dc-title">Generate a keyed hash value using the HMAC method and the contents of a given file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.hash-hmac-file-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>hash_hmac_file</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$algo</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$key</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$raw_output</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
  ] )</div>


 </div>

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

    
     <dt>
<code class="parameter">algo</code></dt>

     <dd>

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

    
    
     <dt>
<code class="parameter">filename</code></dt>

     <dd>

      <p class="para">
       URL describing location of file to be hashed; Supports fopen wrappers.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">key</code></dt>

     <dd>

      <p class="para">
       Shared secret key used for generating the HMAC variant of the message digest.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">raw_output</code></dt>

     <dd>

      <p class="para">
       When set to <strong><code>TRUE</code></strong>, outputs raw binary data.
       <strong><code>FALSE</code></strong> outputs lowercase hexits.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.hash-hmac-file-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a string containing the calculated message digest as lowercase hexits
   unless <code class="parameter">raw_output</code> is set to true in which case the raw
   binary representation of the message digest is returned.
   Returns <strong><code>FALSE</code></strong> when <code class="parameter">algo</code> is unknown or is a
   non-cryptographic hash function, or if the file
   <code class="parameter">filename</code> cannot be read.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.hash-hmac-file-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.2.0</td>
       <td>Usage of non-cryptographic hash functions (adler32, crc32, crc32b, fnv132, fnv1a32, fnv164, fnv1a64, joaat) was disabled.</td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.hash-hmac-file-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-928">
    <p><strong>Example #1 <span class="function"><strong>hash_hmac_file()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Create&nbsp;a&nbsp;file&nbsp;to&nbsp;calculate&nbsp;hash&nbsp;of&nbsp;*/<br /></span><span style="color: #0000BB">file_put_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'example.txt'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'The&nbsp;quick&nbsp;brown&nbsp;fox&nbsp;jumped&nbsp;over&nbsp;the&nbsp;lazy&nbsp;dog.'</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">hash_hmac_file</span><span style="color: #007700">(</span><span style="color: #DD0000">'md5'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'example.txt'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'secret'</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>
7eb2b5c37443418fc77c136dd20e859c
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.hash-hmac-file-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.hash-hmac-algos.html" class="function" rel="rdfs-seeAlso">hash_hmac_algos()</a> - Return a list of registered hashing algorithms suitable for hash_hmac</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-file.html" class="function" rel="rdfs-seeAlso">hash_file()</a> - Generate a hash value using 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-algos.html">hash_hmac_algos</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.hash-hmac.html">hash_hmac</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>