cvs: phpdoc /en/functions mhash.xml

From: Date: Tue, 17 Oct 2000 19:44:10 +0000
Subject: cvs: phpdoc /en/functions mhash.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969332511@lists.php.net to get a copy of this message
nmav Tue Oct 17 12:44:10 2000 EDT Modified files: /phpdoc/en/functions mhash.xml Log: Updated the mhash documentation for the HMAC functionality. Index: phpdoc/en/functions/mhash.xml diff -u phpdoc/en/functions/mhash.xml:1.4 phpdoc/en/functions/mhash.xml:1.5 --- phpdoc/en/functions/mhash.xml:1.4 Sat Jun 24 07:42:10 2000 +++ phpdoc/en/functions/mhash.xml Tue Oct 17 12:44:10 2000 @@ -19,29 +19,31 @@ this extension. </para> <para> - Mhash can be used to create checksums, message digests, and - more. + Mhash can be used to create checksums, message digests, message + authentication codes, and more. </para> <para> <example> - <title>Compute the SHA1 key and print it out as hex</title> + <title>Compute the MD5 digest and hmac 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"; +$input = "what do ya want for nothing?"; +$hash = mhash (MHASH_MD5, $input); +print "The hash is ".bin2hex ($hash)."\n<br>"; +$hash = mhash (MHASH_MD5, $input, "Jefe"); +print "The hmac is ".bin2hex ($hash)."\n<br>"; ?&gt; </programlisting> </example> This will produce: <programlisting> -The hash is d3b85d710d8f6e4e5efd4d5e67d041f9cecedafe +The hash is d03cb659cbf9192dcd066272249f8412 +The hmac is 750c783e6ab0b503eaa86e310a5db738 </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. + access TIGER you use the PHP constant MHASH_TIGER. </para> <para> Here is a list of hashes which are currently supported by mhash. If a @@ -60,27 +62,27 @@ </listitem> <listitem> <simpara> - MHASH_HAVAL + MHASH_HAVAL256 </simpara> </listitem> <listitem> <simpara> - MHASH_RIPEMD160 + MHASH_HAVAL192 </simpara> </listitem> <listitem> <simpara> - MHASH_RIPEMD128 + MHASH_HAVAL160 </simpara> </listitem> <listitem> <simpara> - MHASH_SNEFRU + MHASH_HAVAL128 </simpara> </listitem> <listitem> <simpara> - MHASH_TIGER + MHASH_RIPEMD160 </simpara> </listitem> <listitem> @@ -90,6 +92,11 @@ </listitem> <listitem> <simpara> + MHASH_TIGER + </simpara> + </listitem> + <listitem> + <simpara> MHASH_CRC32 </simpara> </listitem> @@ -217,12 +224,17 @@ <funcdef>string <function>mhash</function></funcdef> <paramdef>int <parameter>hash</parameter></paramdef> <paramdef>string <parameter>data</parameter></paramdef> + <paramdef>string <parameter>[ key ]</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <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). + returns the resulting hash (also called digest). If the <parameter> key</parameter> + is specified it will return the resulting HMAC. HMAC is keyed hashing + for message authentication, or simply a message digest that depends on + the specified key. Not all algorithms supported in mhash can be used in + HMAC mode and will return an error. </para> </refsect1> </refentry>

« previous php.doc (#969332511) next »