reference/hash/functions/hash-hmac-file.xml
539a9823a805ac29cab7fa4baf3ae3a28116a2f5
539a9823a805ac29cab7fa4baf3ae3a28116a2f5
...
...
@@ -8,11 +8,11 @@
8
8
<refsect1 role="description">
9
9
&reftitle.description;
10
10
<methodsynopsis>
11
-
<type>string</type><methodname>hash_hmac_file</methodname>
11
+
<type class="union"><type>string</type><type>false</type></type><methodname>hash_hmac_file</methodname>
12
12
<methodparam><type>string</type><parameter>algo</parameter></methodparam>
13
13
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
14
-
<methodparam><type>string</type><parameter>key</parameter></methodparam>
15
-
<methodparam choice="opt"><type>bool</type><parameter>raw_output</parameter><initializer>false</initializer></methodparam>
14
+
<methodparam><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>key</parameter></methodparam>
15
+
<methodparam choice="opt"><type>bool</type><parameter>binary</parameter><initializer>&false;</initializer></methodparam>
16
16
</methodsynopsis>
17
17
18
18
</refsect1>
...
...
@@ -24,7 +24,13 @@
24
24
<term><parameter>algo</parameter></term>
25
25
<listitem>
26
26
<para>
27
-
Name of selected hashing algorithm (i.e. "md5", "sha256", "haval160,4", etc..) See <function>hash_algos</function> for a list of supported algorithms.
27
+
Name of selected hashing algorithm (e.g. <literal>"sha256"</literal>).
28
+
For a list of supported algorithms see <function>hash_hmac_algos</function>.
29
+
<note>
30
+
<para>
31
+
Non-cryptographic hash functions are not allowed.
32
+
</para>
33
+
</note>
28
34
</para>
29
35
</listitem>
30
36
</varlistentry>
...
...
@@ -45,7 +51,7 @@
45
51
</listitem>
46
52
</varlistentry>
47
53
<varlistentry>
48
-
<term><parameter>raw_output</parameter></term>
54
+
<term><parameter>binary</parameter></term>
49
55
<listitem>
50
56
<para>
51
57
When set to &true;, outputs raw binary data.
...
...
@@ -61,8 +67,47 @@
61
67
&reftitle.returnvalues;
62
68
<para>
63
69
Returns a string containing the calculated message digest as lowercase hexits
64
-
unless <parameter>raw_output</parameter> is set to true in which case the raw
70
+
unless <parameter>binary</parameter> is set to true in which case the raw
65
71
binary representation of the message digest is returned.
72
+
Returns &false; if the file <parameter>filename</parameter> cannot be read.
73
+
</para>
74
+
</refsect1>
75
+
76
+
<refsect1 role="errors">
77
+
&reftitle.errors;
78
+
<para>
79
+
Throws a <classname>ValueError</classname> exception if
80
+
<parameter>algo</parameter> is unknown or is a non-cryptographic hash function.
81
+
</para>
82
+
</refsect1>
83
+
84
+
<refsect1 role="changelog">
85
+
&reftitle.changelog;
86
+
<para>
87
+
<informaltable>
88
+
<tgroup cols="2">
89
+
<thead>
90
+
<row>
91
+
<entry>&Version;</entry>
92
+
<entry>&Description;</entry>
93
+
</row>
94
+
</thead>
95
+
<tbody>
96
+
<row>
97
+
<entry>8.0.0</entry>
98
+
<entry>
99
+
Now throws a <classname>ValueError</classname> exception if
100
+
<parameter>algo</parameter> is unknown or is a non-cryptographic hash
101
+
function; previously, &false; was returned instead.
102
+
</entry>
103
+
</row>
104
+
<row>
105
+
<entry>7.2.0</entry>
106
+
<entry>Usage of non-cryptographic hash functions (adler32, crc32, crc32b, fnv132, fnv1a32, fnv164, fnv1a64, joaat) was disabled.</entry>
107
+
</row>
108
+
</tbody>
109
+
</tgroup>
110
+
</informaltable>
66
111
</para>
67
112
</refsect1>
68
113
...
...
@@ -77,14 +122,14 @@
77
122
/* Create a file to calculate hash of */
78
123
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.');
79
124
80
-
echo hash_hmac_file('md5', 'example.txt', 'secret');
125
+
echo hash_hmac_file('sha256', 'example.txt', 'secret');
81
126
?>
82
127
]]>
83
128
</programlisting>
84
129
&example.outputs;
85
130
<screen>
86
131
<![CDATA[
87
-
7eb2b5c37443418fc77c136dd20e859c
132
+
9c5c42422b03f0ee32949920649445e417b2c634050833c5165704b825c2a53b
88
133
]]>
89
134
</screen>
90
135
</example>
...
...
@@ -95,15 +140,15 @@ echo hash_hmac_file('md5', 'example.txt', 'secret');
95
140
&reftitle.seealso;
96
141
<para>
97
142
<simplelist>
98
-
<member><function>hash_algos</function></member>
99
143
<member><function>hash_hmac</function></member>
100
-
<member><function>hash_file</function></member>
144
+
<member><function>hash_hmac_algos</function></member>
145
+
<member><function>hash_init</function></member>
146
+
<member><function>hash_equals</function></member>
101
147
</simplelist>
102
148
</para>
103
149
</refsect1>
104
150
105
151
</refentry>
106
-
107
152
<!-- Keep this comment at the end of the file
108
153
Local variables:
109
154
mode: sgml
110
155