Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5750

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>Calculate the sha1 hash of a file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.setlocale.html">setlocale</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.sha1.html">sha1</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.sha1-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sha1_file</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">sha1_file</span> &mdash; <span class="dc-title">Calculate the sha1 hash of a file</span></p>

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

  <p class="simpara">
   Calculates the sha1 hash of the file specified by
   <em><code class="parameter">filename</code></em> using the
   <a href="http://www.faqs.org/rfcs/rfc3174" class="link external">&raquo;&nbsp;US Secure Hash Algorithm 1</a>,
   and returns that hash. The hash is a 40-character hexadecimal number.
  </p>
 </div>


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

    <dt>

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

      <p class="para">
       The filename of the file to hash.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       When <strong><code>TRUE</code></strong>, returns the digest in raw binary format with a length of
       20.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sha1-file-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a string on success, <strong><code>FALSE</code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.sha1-file-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4860">
    <p><strong>Example #1  <span class="function"><strong>sha1_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: #007700">foreach(</span><span style="color: #0000BB">glob</span><span style="color: #007700">(</span><span style="color: #DD0000">'/home/Kalle/myproject/*.php'</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$ent</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">is_dir</span><span style="color: #007700">(</span><span style="color: #0000BB">$ent</span><span style="color: #007700">))<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$ent&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">'&nbsp;(SHA1:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">sha1_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$ent</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">')'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.sha1-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>5.1.0</td>
       <td>
        Changed the function to use the streams API. It means that you can use
        it with wrappers, like <em>sha1_file(&#039;http://example.com/..&#039;)</em>
       </td>
      </tr>

      <tr>
       <td>5.0.0</td>
       <td>
        Added the <em><code class="parameter">raw_output</code></em> parameter
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.sha1-file-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.sha1.html" class="function" rel="rdfs-seeAlso">sha1()</a> - Calculate the sha1 hash of a string</span></li>
    <li class="member"> <span class="function"><a href="function.md5-file.html" class="function" rel="rdfs-seeAlso">md5_file()</a> - Calculates the md5 hash of a given file</span></li>
    <li class="member"> <span class="function"><a href="function.crc32.html" class="function" rel="rdfs-seeAlso">crc32()</a> - Calculates the crc32 polynomial of a string</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.setlocale.html">setlocale</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.sha1.html">sha1</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>