uTools-Manuals/docs/php/sha1_file.html
2019-04-28 19:00:34 +08:00

127 lines
5.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>计算文件的 sha1 散列值</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><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, PHP 7)</p><p class="refpurpose"><span class="refname">sha1_file</span> &mdash; <span class="dc-title">计算文件的 sha1 散列值</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.sha1-file-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<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"> = <strong><code>FALSE</code></strong></span></span>
] ) : <span class="type">string</span></div>
<p class="simpara">
利用<a href="http://www.faqs.org/rfcs/rfc3174" class="link external">&raquo;&nbsp;美国安全散列算法 1</a>,计算并返回由 <code class="parameter">filename</code> 指定的文件的 sha1 散列值。该散列值是一个 40 字符长度的十六进制数字。
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.sha1-file-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">filename</code></dt>
<dd>
<p class="para">
要散列的文件的文件名。
</p>
</dd>
<dt>
<code class="parameter">raw_output</code></dt>
<dd>
<p class="para">
如果被设置为 <strong><code>TRUE</code></strong>sha1 摘要将以 20 字符长度的原始格式返回。
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.sha1-file-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功返回一个字符串,否则返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.sha1-file-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-5937">
<p><strong>Example #1 <span class="function"><strong>sha1_file()</strong></span> 范例</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><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>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 changelog" id="refsect1-function.sha1-file-changelog">
<h3 class="title">更新日志</h3>
<p class="para">
<table class="doctable informaltable">
<thead>
<tr>
<th>版本</th>
<th>说明</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td>5.1.0</td>
<td>
改变函数以使用流 API。这意味着可以使用包装器比如 <em>sha1_file(&#039;http://example.com/..&#039;)</em>
</td>
</tr>
</tbody>
</table>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.sha1-file-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="sha1.html" class="function" rel="rdfs-seeAlso">sha1()</a> - 计算字符串的 sha1 散列值</span></li>
<li class="member"><span class="function"><a href="md5_file.html" class="function" rel="rdfs-seeAlso">md5_file()</a> - 计算指定文件的 MD5 散列值</span></li>
<li class="member"><span class="function"><a href="crc32.html" class="function" rel="rdfs-seeAlso">crc32()</a> - 计算一个字符串的 crc32 多项式</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>