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_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,9 +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.
66
-
Returns &false; when <parameter>algo</parameter> is unknown.
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.
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
101
+
non-cryptographic hash 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>
67
111
</para>
68
112
</refsect1>
69
113
...
...
@@ -75,14 +119,14 @@
75
119
<programlisting role="php">
76
120
<![CDATA[
77
121
<?php
78
-
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');
79
123
?>
80
124
]]>
81
125
</programlisting>
82
126
&example.outputs;
83
127
<screen>
84
128
<![CDATA[
85
-
b8e7ae12510bdfb1812e463a7f086122cf37e4f7
129
+
9c5c42422b03f0ee32949920649445e417b2c634050833c5165704b825c2a53b
86
130
]]>
87
131
</screen>
88
132
</example>
...
...
@@ -93,16 +137,14 @@ b8e7ae12510bdfb1812e463a7f086122cf37e4f7
93
137
&reftitle.seealso;
94
138
<para>
95
139
<simplelist>
96
-
<member><function>hash</function></member>
97
-
<member><function>hash_algos</function></member>
98
-
<member><function>hash_init</function></member>
140
+
<member><function>hash_hmac_algos</function></member>
99
141
<member><function>hash_hmac_file</function></member>
142
+
<member><function>hash_equals</function></member>
100
143
</simplelist>
101
144
</para>
102
145
</refsect1>
103
146
104
147
</refentry>
105
-
106
148
<!-- Keep this comment at the end of the file
107
149
Local variables:
108
150
mode: sgml
109
151