Skip to content

Commit

Permalink
Sync hash
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Oct 15, 2023
1 parent af3f787 commit eaad39b
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 66 deletions.
15 changes: 7 additions & 8 deletions reference/hash/functions/hash-copy.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: f3e46c7b29574706553f3d892c86aa78ded9e4c0 Maintainer: yuanyuqiang Status: ready -->
<!-- Reviewed: no -->

<!-- EN-Revision: 584a9fb976cccc93109776a904ec1c5ddb2d580f Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: Luffy -->
<refentry xml:id="function.hash-copy" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>hash_copy</refname>
Expand Down Expand Up @@ -71,24 +70,24 @@
<programlisting role="php">
<![CDATA[
<?php
$context = hash_init("md5");
hash_update($context, "data");
$context = hash_init("sha256");
hash_update($context, "The quick brown fox ");
/* 拷贝上下文资源以便继续使用 */
$copy_context = hash_copy($context);
echo hash_final($context), "\n";
hash_update($copy_context, "data");
hash_update($copy_context, "jumped over the lazy dog.");
echo hash_final($copy_context), "\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
8d777f385d3dfec8815d20f7496026dc
511ae0b1c13f95e5f08f1a0dd3da3d93
b29d66e56ed90cce9b0165c43fedec612b60a071974d8be4513e18580d55b5bd
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
]]>
</screen>
</example>
Expand Down
19 changes: 11 additions & 8 deletions reference/hash/functions/hash-file.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: ac6b36357e5f5294a2c0577b85d193d84f0017ff Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 20dcfbb0dd7150cbe5dfd7903a3001229295c549 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry xml:id="function.hash-file" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand All @@ -27,7 +27,7 @@
<term><parameter>algo</parameter></term>
<listitem>
<para>
要使用的散列算法的名称(例如:"md5","sha256","haval160,4" 等)。
要使用的散列算法的名称(例如:md5”、“sha256”、“haval160,4等)。
可以在 <function>hash_algos</function> 中查看当前支持的算法。
</para>
</listitem>
Expand All @@ -36,7 +36,7 @@
<term><parameter>filename</parameter></term>
<listitem>
<para>
要进行散列运算的文件位置的 URL ;支持 fopen 封装协议。
要进行散列运算的文件位置的 URL;支持 fopen 封装协议。
</para>
</listitem>
</varlistentry>
Expand Down Expand Up @@ -95,18 +95,21 @@
&reftitle.examples;
<para>
<example>
<title><function>hash</function> 示例</title>
<title><function>hash_file</function> 示例</title>
<programlisting role="php">
<![CDATA[
<![CDATA[
<?php
echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.');
/* Create a file to calculate hash of */
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.');
echo hash_file('sha256', 'example.txt');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
ec457d0a974c48d5685a7efa03d137dc8bbde7e3
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
]]>
</screen>
</example>
Expand Down
28 changes: 2 additions & 26 deletions reference/hash/functions/hash-final.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: dabaf662b17f594cd536ff68ea807b0fbc99d0ee Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 20dcfbb0dd7150cbe5dfd7903a3001229295c549 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.hash-final" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>hash_final</refname>
Expand Down Expand Up @@ -72,30 +72,6 @@
</para>
</refsect1>

<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>hash_final</function> 示例</title>
<programlisting role="php">
<![CDATA[
<?php
$ctx = hash_init('sha1');
hash_update($ctx, 'The quick brown fox jumped over the lazy dog.');
echo hash_final($ctx);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
c0854fb9fb03c41cce3802cb0d220529e6eef94e
]]>
</screen>
</example>
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<para>
Expand Down
6 changes: 3 additions & 3 deletions reference/hash/functions/hash-hmac-file.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 91e303f2d27cbca485137230fa7d2e50e75f19a6 Maintainer: yuanyuqiang Status: ready -->
<!-- EN-Revision: 50960545e781ff94ba371befc04346de48a0bb82 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: Luffy, mowangjuanzi -->
<refentry xml:id="function.hash-hmac-file" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -117,14 +117,14 @@
/* 创建一个要计算散列值的文件 */
file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.');
echo hash_hmac_file('md5', 'example.txt', 'secret');
echo hash_hmac_file('sha256', 'example.txt', 'secret');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
7eb2b5c37443418fc77c136dd20e859c
9c5c42422b03f0ee32949920649445e417b2c634050833c5165704b825c2a53b
]]>
</screen>
</example>
Expand Down
9 changes: 5 additions & 4 deletions reference/hash/functions/hash-hmac.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 91e303f2d27cbca485137230fa7d2e50e75f19a6 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 33b00cc27920489594afa964ffbf2660e4e245f7 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.hash-hmac" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>hash_hmac</refname>
Expand Down Expand Up @@ -112,14 +112,14 @@
<programlisting role="php">
<![CDATA[
<?php
echo hash_hmac('ripemd160', 'The quick brown fox jumped over the lazy dog.', 'secret');
echo hash_hmac('sha256', 'The quick brown fox jumped over the lazy dog.', 'secret');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
b8e7ae12510bdfb1812e463a7f086122cf37e4f7
9c5c42422b03f0ee32949920649445e417b2c634050833c5165704b825c2a53b
]]>
</screen>
</example>
Expand All @@ -134,6 +134,7 @@ b8e7ae12510bdfb1812e463a7f086122cf37e4f7
<member><function>hash_hmac_algos</function></member>
<member><function>hash_init</function></member>
<member><function>hash_hmac_file</function></member>
<member><function>hash_equals</function></member>
</simplelist>
</para>
</refsect1>
Expand Down
16 changes: 11 additions & 5 deletions reference/hash/functions/hash-init.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 91e303f2d27cbca485137230fa7d2e50e75f19a6 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 20dcfbb0dd7150cbe5dfd7903a3001229295c549 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry xml:id="function.hash-init" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -127,17 +127,23 @@
<programlisting role="php">
<![CDATA[
<?php
$ctx = hash_init('md5');
$hash = hash('sha256', 'The quick brown fox jumped over the lazy dog.');
$ctx = hash_init('sha256');
hash_update($ctx, 'The quick brown fox ');
hash_update($ctx, 'jumped over the lazy dog.');
echo hash_final($ctx);
$incremental_hash = hash_final($ctx);
echo $incremental_hash, PHP_EOL;
var_dump($hash === $incremental_hash);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
5c6ffbdd40d9556b73a21e63c3e0e904
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
bool(true)
]]>
</screen>
</example>
Expand Down
11 changes: 6 additions & 5 deletions reference/hash/functions/hash-update-stream.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: dabaf662b17f594cd536ff68ea807b0fbc99d0ee Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 20dcfbb0dd7150cbe5dfd7903a3001229295c549 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.hash-update-stream" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>hash_update_stream</refname>
Expand Down Expand Up @@ -89,10 +89,11 @@
<![CDATA[
<?php
$fp = tmpfile();
fwrite($fp, 'The quick brown fox jumped over the lazy dog.');
fwrite($fp, 'jumped over the lazy dog.');
rewind($fp);
$ctx = hash_init('md5');
$ctx = hash_init('sha256');
hash_update($ctx, 'The quick brown fox ');
hash_update_stream($ctx, $fp);
echo hash_final($ctx);
?>
Expand All @@ -101,7 +102,7 @@ echo hash_final($ctx);
&example.outputs;
<screen>
<![CDATA[
5c6ffbdd40d9556b73a21e63c3e0e904
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
]]>
</screen>
</example>
Expand Down
8 changes: 4 additions & 4 deletions reference/hash/functions/hash.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 4b4c8b47408da359d4d0ab39f19673f006895908 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 20dcfbb0dd7150cbe5dfd7903a3001229295c549 Maintainer: yuanyuqiang Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.hash" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>hash</refname>
Expand Down Expand Up @@ -105,14 +105,14 @@
<programlisting role="php">
<![CDATA[
<?php
echo hash('ripemd160', 'The quick brown fox jumped over the lazy dog.');
echo hash('sha256', 'The quick brown fox jumped over the lazy dog.');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
ec457d0a974c48d5685a7efa03d137dc8bbde7e3
68b1282b91de2c054c36629cb8dd447f12f096d3e3c587978dc2248444633483
]]>
</screen>
</example>
Expand Down
6 changes: 3 additions & 3 deletions reference/url/functions/get-headers.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 06791a63aa7aa896e38a9ffab57f1fe49c48a841 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<!-- EN-Revision: 943c1285bd3808ad764f01da00b59458110133c0 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.get-headers" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>get_headers</refname>
Expand Down Expand Up @@ -154,7 +154,7 @@ $context = stream_context_create(
)
]
);
$headers = get_headers('http://example.com', $context);
$headers = get_headers('http://example.com', false, $context);
?>
]]>
</programlisting>
Expand Down

0 comments on commit eaad39b

Please sign in to comment.