reference/hash/functions/hash-hmac.xml
539a9823a805ac29cab7fa4baf3ae3a28116a2f5
539a9823a805ac29cab7fa4baf3ae3a28116a2f5
...
...
@@ -11,8 +11,8 @@
11
11
<type>string</type><methodname>hash_hmac</methodname>
12
12
<methodparam><type>string</type><parameter>algo</parameter></methodparam>
13
13
<methodparam><type>string</type><parameter>data</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_hmac_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,10 +67,17 @@
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.
66
-
Returns &false; when <parameter>algo</parameter> is unknown or is a
67
-
non-cryptographic hash function.
72
+
</para>
73
+
</refsect1>
74
+
75
+
<refsect1 role="errors">
76
+
&reftitle.errors;
77
+
<para>
78
+
Throws a <classname>ValueError</classname> exception if
79
+
<parameter>algo</parameter> is unknown or is a non-cryptographic hash
80
+
function.
68
81
</para>
69
82
</refsect1>
70
83
...
...
@@ -80,6 +93,14 @@
80
93
</row>
81
94
</thead>
82
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
101
+
non-cryptographic hash function; previously, &false; was returned instead.
102
+
</entry>
103
+
</row>
83
104
<row>
84
105
<entry>7.2.0</entry>
85
106
<entry>Usage of non-cryptographic hash functions (adler32, crc32, crc32b, fnv132, fnv1a32, fnv164, fnv1a64, joaat) was disabled.</entry>
...
...
@@ -98,14 +119,14 @@
98
119
<programlisting role="php">
99
120
<![CDATA[
100
121
<?php
101
-
echo hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret');
122
+
echo hash_hmac('sha256', 'The quick brown fox jumped over the lazy dog.', 'secret');
102
123
?>
103
124
]]>
104
125
</programlisting>
105
126
&example.outputs;
106
127
<screen>
107
128
<![CDATA[
108
-
b8e7ae12510bdfb1812e463a7f086122cf37e4f7
129
+
9c5c42422b03f0ee32949920649445e417b2c634050833c5165704b825c2a53b
109
130
]]>
110
131
</screen>
111
132
</example>
...
...
@@ -116,16 +137,14 @@ b8e7ae12510bdfb1812e463a7f086122cf37e4f7
116
137
&reftitle.seealso;
117
138
<para>
118
139
<simplelist>
119
-
<member><function>hash</function></member>
120
140
<member><function>hash_hmac_algos</function></member>
121
-
<member><function>hash_init</function></member>
122
141
<member><function>hash_hmac_file</function></member>
142
+
<member><function>hash_equals</function></member>
123
143
</simplelist>
124
144
</para>
125
145
</refsect1>
126
146
127
147
</refentry>
128
-
129
148
<!-- Keep this comment at the end of the file
130
149
Local variables:
131
150
mode: sgml
132
151