<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.hash.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.hash-file.php',
    1 => 'hash_file',
    2 => 'Berechnet den Hash des Inhalts einer Datei',
  ),
  'up' => 
  array (
    0 => 'ref.hash.php',
    1 => 'Hash-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.hash-equals.php',
    1 => 'hash_equals',
  ),
  'next' => 
  array (
    0 => 'function.hash-final.php',
    1 => 'hash_final',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/hash/functions/hash-file.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.hash-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">hash_file</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PHP 7, PHP 8, PECL hash &gt;= 1.1)</p><p class="refpurpose"><span class="refname">hash_file</span> &mdash; <span class="dc-title">Berechnet den Hash des Inhalts einer Datei</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.hash-file-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>hash_file</strong></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">$algo</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">$filename</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$binary</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code><span class="initializer"> = []</span></span><br>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.hash-file-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">algo</code></dt>
     <dd>
      <p class="para">
       Der Name des gewählten Hash-Algorithmus (z. B.
       <code class="literal">&quot;sha256&quot;</code>). Für eine Liste der unterstützten
       Algorithmen siehe <span class="function"><a href="function.hash-algos.php" class="function">hash_algos()</a></span>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       Die URL der Datei, die gehasht werden soll;
       <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>-Wrapper werden unterstützt.
      </p>
     </dd>
    
    
     <dt><code class="parameter">binary</code></dt>
     <dd>
      <p class="para">
       Ist dieser Parameter auf <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> gesetzt, werden direkt Binärdaten
       zurückgegeben, andernfalls werden kleingeschriebene Hexadezimalziffern
       zurückgegeben.
      </p>
     </dd>
    
    
     <dt><code class="parameter">options</code></dt>
     <dd>
      <p class="para">
       Ein Array mit Optionen für die verschiedenen Hash-Algorithmen. Derzeit
       wird von den MurmurHash-Varianten nur der Parameter
       <code class="literal">&quot;seed&quot;</code> unterstützt.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.hash-file-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt den berechneten Hash als Hexadezimalzahl zurück, außer
   <code class="parameter">binary</code> ist auf <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> gesetzt, in diesem Fall wird
   die binäre Darstellung des Hashes zurückgegeben. Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>


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

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.1.0</td>
       <td>
        Der Parameter <code class="parameter">options</code> wurde hinzugefügt.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.hash-file-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>hash_file()</strong></span>-Beispiel</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Erstelle die Datei, deren Inhalt gehasht werden soll */<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">, </span><span style="color: #DD0000">'Franz jagt im komplett verwahrlosten Taxi quer durch Bayern.'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">hash_file</span><span style="color: #007700">(</span><span style="color: #DD0000">'sha256'</span><span style="color: #007700">, </span><span style="color: #DD0000">'example.txt'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">0b3a381e71cda8f3abe88b1dc3eb9aa2a53fa033e9802878edd1959c267281a2</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.hash-file-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.hash-init.php" class="function" rel="rdfs-seeAlso">hash_init()</a> - Initialisiert einen schrittweisen Hashing-Kontext</span></li>
    <li><span class="function"><a href="function.hash-hmac-file.php" class="function" rel="rdfs-seeAlso">hash_hmac_file()</a> - Berechnet einen Hash einer Datei mit Schl&uuml;ssel unter Verwendung von HMAC</span></li>
   </ul>
  </p>
 </div>


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