mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 13:57:03 +08:00
160 lines
6.1 KiB
HTML
160 lines
6.1 KiB
HTML
<!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>使用 HMAC 方法和给定文件的内容生成带密钥的哈希值</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.hash-hmac-file" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">hash_hmac_file</h1>
|
||
<p class="verinfo">(PHP 5 >= 5.1.2, PHP 7, PECL hash >= 1.1)</p><p class="refpurpose"><span class="refname">hash_hmac_file</span> — <span class="dc-title">使用 HMAC 方法和给定文件的内容生成带密钥的哈希值</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 description" id="refsect1-function.hash-hmac-file-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<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>
|
||
] ) : <span class="type">string</span></div>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.hash-hmac-file-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">algo</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
要使用的哈希算法名称,例如:"md5","sha256","haval160,4" 等。
|
||
如何获取受支持的算法清单,请参见 <span class="function"><a href="hash_hmac_algos.html" class="function">hash_hmac_algos()</a></span> 函数。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">filename</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
要进行哈希运算的文件路径,支持 fopen 封装器。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">key</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
使用 HMAC 生成信息摘要时所使用的密钥。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">raw_output</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
设置为 <strong><code>TRUE</code></strong> 输出原始二进制数据,
|
||
设置为 <strong><code>FALSE</code></strong> 输出小写 16 进制字符串。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.hash-hmac-file-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
如果 <code class="parameter">raw_output</code> 设置为 <strong><code>TRUE</code></strong>, 则返回原始二进制数据表示的信息摘要,
|
||
否则返回 16 进制小写字符串格式表示的信息摘要。
|
||
如果 <code class="parameter">algo</code> 参数指定的不是受支持的算法,或者无法读取 <code class="parameter">filename</code> 给定的文件,则返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 changelog" id="refsect1-function.hash-hmac-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>7.2.0</td>
|
||
<td>不再支持非加密的哈希函数(adler32,crc32,crc32b,fnv132,fnv1a32,fnv164,fnv1a64,joaat)。</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 examples" id="refsect1-function.hash-hmac-file-examples">
|
||
<h3 class="title">范例</h3>
|
||
<p class="para">
|
||
<div class="example" id="example-895">
|
||
<p><strong>Example #1 <span class="function"><strong>hash_hmac_file()</strong></span> 例程</strong></p>
|
||
<div class="example-contents">
|
||
<div class="phpcode"><pre><span style="color: #000000">
|
||
<span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">/* 创建一个要计算哈希值的文件 */<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">'The quick brown fox jumped over the lazy dog.'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">hash_hmac_file</span><span style="color: #007700">(</span><span style="color: #DD0000">'md5'</span><span style="color: #007700">, </span><span style="color: #DD0000">'example.txt'</span><span style="color: #007700">, </span><span style="color: #DD0000">'secret'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
||
</span>
|
||
</pre></div>
|
||
</div>
|
||
|
||
<div class="example-contents"><p>以上例程会输出:</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">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member"><span class="function"><a href="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="hash_hmac.html" class="function" rel="rdfs-seeAlso">hash_hmac()</a> - 使用 HMAC 方法生成带有密钥的哈希值</span></li>
|
||
<li class="member"><span class="function"><a href="hash_file.html" class="function" rel="rdfs-seeAlso">hash_file()</a> - 使用给定文件的内容生成哈希值</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |