reference/hash/functions/hash.xml
539a9823a805ac29cab7fa4baf3ae3a28116a2f5
539a9823a805ac29cab7fa4baf3ae3a28116a2f5
...
...
@@ -11,7 +11,8 @@
11
11
<type>string</type><methodname>hash</methodname>
12
12
<methodparam><type>string</type><parameter>algo</parameter></methodparam>
13
13
<methodparam><type>string</type><parameter>data</parameter></methodparam>
14
-
<methodparam choice="opt"><type>bool</type><parameter>raw_output</parameter><initializer>&false;</initializer></methodparam>
14
+
<methodparam choice="opt"><type>bool</type><parameter>binary</parameter><initializer>&false;</initializer></methodparam>
15
+
<methodparam choice="opt"><type>array</type><parameter>options</parameter><initializer>[]</initializer></methodparam>
15
16
</methodsynopsis>
16
17
17
18
</refsect1>
...
...
@@ -23,7 +24,8 @@
23
24
<term><parameter>algo</parameter></term>
24
25
<listitem>
25
26
<para>
26
-
Name of selected hashing algorithm (i.e. "md5", "sha256", "haval160,4", etc..). For a list of supported algorithms see <function>hash_algos</function>.
27
+
Name of selected hashing algorithm (e.g. <literal>"sha256"</literal>).
28
+
For a list of supported algorithms see <function>hash_algos</function>.
27
29
</para>
28
30
</listitem>
29
31
</varlistentry>
...
...
@@ -36,7 +38,7 @@
36
38
</listitem>
37
39
</varlistentry>
38
40
<varlistentry>
39
-
<term><parameter>raw_output</parameter></term>
41
+
<term><parameter>binary</parameter></term>
40
42
<listitem>
41
43
<para>
42
44
When set to &true;, outputs raw binary data.
...
...
@@ -44,6 +46,16 @@
44
46
</para>
45
47
</listitem>
46
48
</varlistentry>
49
+
<varlistentry>
50
+
<term><parameter>options</parameter></term>
51
+
<listitem>
52
+
<para>
53
+
An array of options for the various hashing algorithms.
54
+
Currently, only the <literal>"seed"</literal> parameter is
55
+
supported by the MurmurHash variants.
56
+
</para>
57
+
</listitem>
58
+
</varlistentry>
47
59
</variablelist>
48
60
</para>
49
61
</refsect1>
...
...
@@ -52,12 +64,12 @@
52
64
&reftitle.returnvalues;
53
65
<para>
54
66
Returns a string containing the calculated message digest as lowercase hexits
55
-
unless <parameter>raw_output</parameter> is set to true in which case the raw
67
+
unless <parameter>binary</parameter> is set to true in which case the raw
56
68
binary representation of the message digest is returned.
57
69
</para>
58
70
</refsect1>
59
71
60
-
<refsect1 role="changelog">
72
+
<refsect1 role="changelog">
61
73
&reftitle.changelog;
62
74
<para>
63
75
<informaltable>
...
...
@@ -70,8 +82,15 @@
70
82
</thead>
71
83
<tbody>
72
84
<row>
73
-
<entry>5.4.0</entry>
74
-
<entry>The tiger algorithm now uses big-endian byte ordering. See also example below.</entry>
85
+
<entry>8.1.0</entry>
86
+
<entry>The <parameter>options</parameter> parameter has been added.</entry>
87
+
</row>
88
+
<row>
89
+
<entry>8.0.0</entry>
90
+
<entry>
91
+
<function>hash</function> now throws a <classname>ValueError</classname> exception
92
+
if <parameter>algo</parameter> is unknown; previously, &false; was returned instead.
93
+
</entry>
75
94
</row>
76
95
</tbody>
77
96
</tgroup>
...
...
@@ -87,54 +106,14 @@
87
106
<programlisting role="php">
88
107
<![CDATA[
89
108
<?php
90
-
echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.');
109
+
echo hash('sha256', 'The quick brown fox jumped over the lazy dog.');
91
110
?>
92
111
]]>
93
112
</programlisting>
94
113
&example.outputs;
95
114
<screen>
96
115
<![CDATA[
97
-
ec457d0a974c48d5685a7efa03d137dc8bbde7e3
98
-
]]>
99
-
</screen>
100
-
</example>
101
-
</para>
102
-
<para>
103
-
<example xml:id="function.hash.tiger-bc">
104
-
<title>Calculate pre PHP-5.4 tiger hashes with PHP-5.4 and higher</title>
105
-
<programlisting role="php">
106
-
<![CDATA[
107
-
<?php
108
-
function old_tiger($data = "", $width=192, $rounds = 3) {
109
-
return substr(
110
-
implode(
111
-
array_map(
112
-
function ($h) {
113
-
return str_pad(bin2hex(strrev($h)), 16, "0");
114
-
},
115
-
str_split(hash("tiger192,$rounds", $data, true), 8)
116
-
)
117
-
),
118
-
0, 48-(192-$width)/4
119
-
);
120
-
}
121
-
echo hash('tiger192,3', 'a-string'), PHP_EOL;
122
-
echo old_tiger('a-string'), PHP_EOL;
123
-
?>
124
-
]]>
125
-
</programlisting>
126
-
&example.outputs.53;
127
-
<screen>
128
-
<![CDATA[
129
-
146a7492719b3564094efe7abbd40a7416fd900179d02773
130
-
64359b7192746a14740ad4bb7afe4e097327d0790190fd16
131
-
]]>
132
-
</screen>
133
-
&example.outputs.54;
134
-
<screen>
135
-
<![CDATA[
136
-
64359b7192746a14740ad4bb7afe4e097327d0790190fd16
137
-
146a7492719b3564094efe7abbd40a7416fd900179d02773
116
+
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
138
117
]]>
139
118
</screen>
140
119
</example>
...
...
@@ -145,17 +124,14 @@ echo old_tiger('a-string'), PHP_EOL;
145
124
&reftitle.seealso;
146
125
<para>
147
126
<simplelist>
127
+
<member><function>hash_init</function></member>
148
128
<member><function>hash_file</function></member>
149
129
<member><function>hash_hmac</function></member>
150
-
<member><function>hash_init</function></member>
151
-
<member><function>md5</function></member>
152
-
<member><function>sha1</function></member>
153
130
</simplelist>
154
131
</para>
155
132
</refsect1>
156
133
157
134
</refentry>
158
-
159
135
<!-- Keep this comment at the end of the file
160
136
Local variables:
161
137
mode: sgml
162
138