reference/hash/functions/hash.xml
20dcfbb0dd7150cbe5dfd7903a3001229295c549
...
...
@@ -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>
...
...
@@ -36,7 +37,7 @@
36
37
</listitem>
37
38
</varlistentry>
38
39
<varlistentry>
39
-
<term><parameter>raw_output</parameter></term>
40
+
<term><parameter>binary</parameter></term>
40
41
<listitem>
41
42
<para>
42
43
When set to &true;, outputs raw binary data.
...
...
@@ -44,6 +45,15 @@
44
45
</para>
45
46
</listitem>
46
47
</varlistentry>
48
+
<varlistentry>
49
+
<term><parameter>options</parameter></term>
50
+
<listitem>
51
+
<para>
52
+
An array of options for the various hashing algorithms. Currently, only the "seed" parameter is
53
+
supported by the MurmurHash variants.
54
+
</para>
55
+
</listitem>
56
+
</varlistentry>
47
57
</variablelist>
48
58
</para>
49
59
</refsect1>
...
...
@@ -52,12 +62,12 @@
52
62
&reftitle.returnvalues;
53
63
<para>
54
64
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
65
+
unless <parameter>binary</parameter> is set to true in which case the raw
56
66
binary representation of the message digest is returned.
57
67
</para>
58
68
</refsect1>
59
69

60
-
<refsect1 role="changelog">
70
+
<refsect1 role="changelog">
61
71
&reftitle.changelog;
62
72
<para>
63
73
<informaltable>
...
...
@@ -70,8 +80,15 @@
70
80
</thead>
71
81
<tbody>
72
82
<row>
73
-
<entry>5.4.0</entry>
74
-
<entry>The tiger algorithm now uses big-endian byte ordering. See also example below.</entry>
83
+
<entry>8.1.0</entry>
84
+
<entry>The <parameter>options</parameter> parameter has been added.</entry>
85
+
</row>
86
+
<row>
87
+
<entry>8.0.0</entry>
88
+
<entry>
89
+
<function>hash</function> now throws a <classname>ValueError</classname> exception
90
+
if <parameter>algo</parameter> is unknown; previously, &false; was returned instead.
91
+
</entry>
75
92
</row>
76
93
</tbody>
77
94
</tgroup>
...
...
@@ -87,54 +104,14 @@
87
104
<programlisting role="php">
88
105
<![CDATA[
89
106
<?php
90
-
echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.');
107
+
echo hash('sha256', 'The quick brown fox jumped over the lazy dog.');
91
108
?>
92
109
]]>
93
110
</programlisting>
94
111
&example.outputs;
95
112
<screen>
96
113
<![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
114
+
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
138
115
]]>
139
116
</screen>
140
117
</example>
...
...
@@ -155,7 +132,6 @@ echo old_tiger('a-string'), PHP_EOL;
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