reference/hash/functions/hash.xml
db22a7cfcbc3af221f67e228336ac3e2d62aaf2c
...
...
@@ -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,16 @@
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.
53
+
Currently, only the <literal>"seed"</literal> parameter is
54
+
supported by the MurmurHash variants.
55
+
</para>
56
+
</listitem>
57
+
</varlistentry>
47
58
</variablelist>
48
59
</para>
49
60
</refsect1>
...
...
@@ -52,12 +63,12 @@
52
63
&reftitle.returnvalues;
53
64
<para>
54
65
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
66
+
unless <parameter>binary</parameter> is set to true in which case the raw
56
67
binary representation of the message digest is returned.
57
68
</para>
58
69
</refsect1>
59
70

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

157
135
</refentry>
158
-

159
136
<!-- Keep this comment at the end of the file
160
137
Local variables:
161
138
mode: sgml
162
139