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,11 +62,40 @@
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

70
+
<refsect1 role="changelog">
71
+
&reftitle.changelog;
72
+
<para>
73
+
<informaltable>
74
+
<tgroup cols="2">
75
+
<thead>
76
+
<row>
77
+
<entry>&Version;</entry>
78
+
<entry>&Description;</entry>
79
+
</row>
80
+
</thead>
81
+
<tbody>
82
+
<row>
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>
92
+
</row>
93
+
</tbody>
94
+
</tgroup>
95
+
</informaltable>
96
+
</para>
97
+
</refsect1>
98
+

60
99
<refsect1 role="examples">
61
100
&reftitle.examples;
62
101
<para>
...
...
@@ -65,54 +104,14 @@
65
104
<programlisting role="php">
66
105
<![CDATA[
67
106
<?php
68
-
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.');
69
108
?>
70
109
]]>
71
110
</programlisting>
72
111
&example.outputs;
73
112
<screen>
74
113
<![CDATA[
75
-
ec457d0a974c48d5685a7efa03d137dc8bbde7e3
76
-
]]>
77
-
</screen>
78
-
</example>
79
-
</para>
80
-
<para>
81
-
<example xml:id="function.hash.tiger-bc">
82
-
<title>Calculate pre PHP-5.4 tiger hashes with PHP-5.4 and higher</title>
83
-
<programlisting role="php">
84
-
<![CDATA[
85
-
<?php
86
-
function old_tiger($data = "", $width=192, $rounds = 3) {
87
-
return substr(
88
-
implode(
89
-
array_map(
90
-
function ($h) {
91
-
return str_pad(bin2hex(strrev($h)), 16, "0");
92
-
},
93
-
str_split(hash("tiger192,$rounds", $data, true), 8)
94
-
)
95
-
),
96
-
0, 48-(192-$width)/4
97
-
);
98
-
}
99
-
echo hash('tiger192,3', 'a-string'), PHP_EOL;
100
-
echo old_tiger('a-string'), PHP_EOL;
101
-
?>
102
-
]]>
103
-
</programlisting>
104
-
&example.outputs.53;
105
-
<screen>
106
-
<![CDATA[
107
-
146a7492719b3564094efe7abbd40a7416fd900179d02773
108
-
64359b7192746a14740ad4bb7afe4e097327d0790190fd16
109
-
]]>
110
-
</screen>
111
-
&example.outputs.54;
112
-
<screen>
113
-
<![CDATA[
114
-
64359b7192746a14740ad4bb7afe4e097327d0790190fd16
115
-
146a7492719b3564094efe7abbd40a7416fd900179d02773
114
+
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
116
115
]]>
117
116
</screen>
118
117
</example>
...
...
@@ -133,7 +132,6 @@ echo old_tiger('a-string'), PHP_EOL;
133
132
</refsect1>
134
133

135
134
</refentry>
136
-

137
135
<!-- Keep this comment at the end of the file
138
136
Local variables:
139
137
mode: sgml
140
138