Changed the title and some cleanup.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@26902 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Egon Schmid 2000-06-24 14:42:10 +00:00
parent 56cc0f7774
commit 4509bcb65f

View file

@ -1,78 +1,105 @@
<reference id="ref.mhash">
<title>Hash functions</title>
<title>Mhash Functions</title>
<titleabbrev>mhash</titleabbrev>
<partintro>
<para>
These functions are intended to work with <ulink url="&url.mhash;">mhash</ulink>.</para>
These functions are intended to work with <ulink
url="&url.mhash;">mhash</ulink>.</para>
<para>
This is an interface to the mhash library. mhash supports a wide variety of
hash algorithms such as MD5, SHA1, GOST, and many others.</para>
This is an interface to the mhash library. mhash supports a wide
variety of hash algorithms such as MD5, SHA1, GOST, and many
others.
</para>
<para>
To use it, download the mhash distribution from <ulink url="&url.mhash;">its web site</ulink> and follow the included
installation instructions. You need to compile PHP with the <option role="configure">--with-mhash</option> parameter to enable this
extension.</para>
To use it, download the mhash distribution from <ulink
url="&url.mhash;">its web site</ulink> and follow the included
installation instructions. You need to compile PHP with the
<option role="configure">--with-mhash</option> parameter to enable
this extension.
</para>
<para>
mhash can be used to create checksums, message digests, and more.</para>
Mhash can be used to create checksums, message digests, and
more.
</para>
<para>
<example>
<title>Compute the SHA1 key and print it out as hex</title>
<programlisting role="php">
&lt;?php
$input = "Let us meet at 9 o' clock at the secret place.";
$hash = mhash(MHASH_SHA1, $input);
print "The hash is ".bin2hex($hash)."\n";
$hash = mhash (MHASH_SHA1, $input);
print "The hash is ".bin2hex ($hash)."\n";
?&gt;
</programlisting>
</example>
This will produce:
<programlisting>
The hash is d3b85d710d8f6e4e5efd4d5e67d041f9cecedafe
</programlisting>
For a complete list of supported hashes, refer to the documentation of
mhash. The general rule is that you can access the hash algorithm from PHP
with MHASH_HASHNAME. For example, to access HAVAL you use the PHP constant
MHASH_HAVAL.</para>
For a complete list of supported hashes, refer to the
documentation of mhash. The general rule is that you can access
the hash algorithm from PHP with MHASH_HASHNAME. For example, to
access HAVAL you use the PHP constant MHASH_HAVAL.
</para>
<para>
Here is a list of hashes which are currently supported by mhash. If a
hash is not listed here, but is listed by mhash as supported, you can
safely assume that this documentation is outdated.
<itemizedlist>
<listitem><simpara>
MHASH_MD5</simpara></listitem>
<listitem><simpara>
MHASH_SHA1</simpara></listitem>
<listitem><simpara>
MHASH_HAVAL</simpara></listitem>
<listitem><simpara>
MHASH_RIPEMD160</simpara></listitem>
<listitem><simpara>
MHASH_RIPEMD128</simpara></listitem>
<listitem><simpara>
MHASH_SNEFRU</simpara></listitem>
<listitem><simpara>
MHASH_TIGER</simpara></listitem>
<listitem><simpara>
MHASH_GOST</simpara></listitem>
<listitem><simpara>
MHASH_CRC32</simpara></listitem>
<listitem><simpara>
MHASH_CRC32B</simpara></listitem>
</itemizedlist></para>
<listitem>
<simpara>
MHASH_MD5
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_SHA1
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_HAVAL
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_RIPEMD160
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_RIPEMD128
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_SNEFRU
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_TIGER
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_GOST
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_CRC32
</simpara>
</listitem>
<listitem>
<simpara>
MHASH_CRC32B
</simpara>
</listitem>
</itemizedlist>
</para>
</partintro>
<refentry id="function.mhash-get-hash-name">
@ -88,32 +115,31 @@ The hash is d3b85d710d8f6e4e5efd4d5e67d041f9cecedafe
<paramdef>int <parameter>hash</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>mhash_get_hash_name</function> is used to get the name of the
specified hash.</para>
<function>Mhash_get_hash_name</function> is used to get the name
of the specified hash.
</para>
<para>
<function>mhash_get_hash_name</function> takes the hash id as an argument
and returns the name of the hash or false, if the hash does not exist.</para>
<function>mhash_get_hash_name</function> takes the hash id as an
argument and returns the name of the hash or false, if the hash
does not exist.
</para>
<para>
<example>
<title>mhash_get_hash_name example</title>
<title><function>Mhash_get_hash_name</function> Example</title>
<programlisting>
&lt;?php
$hash = MHASH_MD5;
print mhash_get_hash_name($hash);
print mhash_get_hash_name ($hash);
?&gt;
</programlisting>
</example>
The above example will print out:
<programlisting>
MD5
</programlisting></para>
</programlisting>
</para>
</refsect1>
</refentry>
@ -130,16 +156,15 @@ MD5
<paramdef>int <parameter>hash</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>mhash_get_block_size</function> is used to get the size of a
block of the specified <parameter>hash</parameter>.</para>
<function>Mhash_get_block_size</function> is used to get the size
of a block of the specified <parameter>hash</parameter>.
</para>
<para>
<function>mhash_get_block_size</function> takes one argument, the
<parameter>hash</parameter> and returns the size in bytes or false, if
the <parameter>hash</parameter> does not exist.</para>
<function>Mhash_get_block_size</function> takes one argument, the
<parameter>hash</parameter> and returns the size in bytes or
false, if the <parameter>hash</parameter> does not exist.
</para>
</refsect1>
</refentry>
@ -156,28 +181,27 @@ MD5
<paramdef>void </paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>mhash_count</function> returns the highest available hash
id. Hashes are numbered from 0 to this hash id.</para>
<function>Mhash_count</function> returns the highest available hash
id. Hashes are numbered from 0 to this hash id.
</para>
<para>
<example>
<title>Traversing all hashes</title>
<programlisting>
<programlisting role="php">
&lt;?php
$nr = mhash_count();
for($i = 0; $i &lt;= $nr; $i++) {
echo sprintf("The blocksize of %s is %d\n",
mhash_get_hash_name($i),
mhash_get_block_size($i));
for ($i = 0; $i &lt;= $nr; $i++) {
echo sprintf ("The blocksize of %s is %d\n",
mhash_get_hash_name ($i),
mhash_get_block_size ($i));
}
?&gt;
</programlisting>
</example></para>
</example>
</para>
</refsect1>
</refentry>
@ -195,12 +219,11 @@ for($i = 0; $i &lt;= $nr; $i++) {
<paramdef>string <parameter>data</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>mhash</function> applies a hash function specified by
<function>Mhash</function> applies a hash function specified by
<parameter>hash</parameter> to the <parameter>data</parameter> and
returns the resulting hash (also called digest).</para>
returns the resulting hash (also called digest).
</para>
</refsect1>
</refentry>
@ -216,7 +239,7 @@ sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../manual.ced"
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil