cvs: phpdoc /it/functions mhash.xml misc.xml

From: Date: Thu, 14 Dec 2000 00:39:17 +0000
Subject: cvs: phpdoc /it/functions mhash.xml misc.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969333256@lists.php.net to get a copy of this message
perugini Wed Dec 13 16:39:17 2000 EDT Modified files: /phpdoc/it/functions misc.xml mhash.xml Log: SYnc with en tree.

Index: phpdoc/it/functions/misc.xml diff -u phpdoc/it/functions/misc.xml:1.6 phpdoc/it/functions/misc.xml:1.7 --- phpdoc/it/functions/misc.xml:1.6 Mon Sep 18 08:57:51 2000 +++ phpdoc/it/functions/misc.xml Wed Dec 13 16:39:17 2000 @@ -171,6 +171,16 @@ <para> Returns true if the named constant given by <parameter>name</parameter> has been defined, false otherwise. + <example> + <title>Checking Constants</title> + <programlisting role="php"> +&lt;?php +if (defined("CONSTANT")){ // Note that it should be quoted + echo CONSTANT; // + } +?&gt; + </programlisting> + </example> </para> <para> See also <function>define</function> and the section on <link @@ -414,7 +424,7 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>void <function>highlight_file</function></funcdef> + <funcdef>boolean <function>highlight_file</function></funcdef> <paramdef>string <parameter>filename</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -422,6 +432,7 @@ The <function>highlight_file</function> function prints out a syntax higlighted version of the code contained in <parameter>filename</parameter> using the colors defined in the built-in syntax highlighter for PHP. + It returns true on success, false otherwise (PHP 4). </simpara> <para> <example> @@ -510,6 +521,7 @@ The <function>highlight_string</function> function prints out a syntax highlighted version of <parameter>str</parameter> using the colors defined in the built-in syntax highlighter for PHP. + It returns true on success, false otherwise (PHP 4). </simpara> <simpara> See also <function>highlight_file</function>, @@ -771,7 +783,7 @@ <title>Description</title> <funcsynopsis> <funcprototype> - <funcdef>void <function>show_source</function></funcdef> + <funcdef>boolean <function>show_source</function></funcdef> <paramdef>string <parameter>filename</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -779,6 +791,7 @@ The <function>show_source</function> function prints out a syntax higlighted version of the code contained in <parameter>filename</parameter> using the colors defined in the built-in syntax highlighter for PHP. + It returns true on success, false otherwise (PHP 4). </simpara> <note> <simpara> Index: phpdoc/it/functions/mhash.xml diff -u phpdoc/it/functions/mhash.xml:1.2 phpdoc/it/functions/mhash.xml:1.3 --- phpdoc/it/functions/mhash.xml:1.2 Sat Jun 24 00:38:44 2000 +++ phpdoc/it/functions/mhash.xml Wed Dec 13 16:39:17 2000 @@ -1,78 +1,112 @@ <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, 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&lt;br>"; +$hash = mhash (MHASH_MD5, $input, "Jefe"); +print "The hmac is ".bin2hex ($hash)."\n&lt;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.</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 TIGER you use the PHP constant MHASH_TIGER. + </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_HAVAL256 + </simpara> + </listitem> + <listitem> + <simpara> + MHASH_HAVAL192 + </simpara> + </listitem> + <listitem> + <simpara> + MHASH_HAVAL160 + </simpara> + </listitem> + <listitem> + <simpara> + MHASH_HAVAL128 + </simpara> + </listitem> + <listitem> + <simpara> + MHASH_RIPEMD160 + </simpara> + </listitem> + <listitem> + <simpara> + MHASH_GOST + </simpara> + </listitem> + <listitem> + <simpara> + MHASH_TIGER + </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 +122,31 @@ <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 +163,15 @@ <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 +188,27 @@ <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> @@ -193,14 +224,55 @@ <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 + <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). 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> + + <refentry id="function.mhash-keygen-s2k"> + <refnamediv> + <refname>mhash_keygen_s2k</refname> + <refpurpose>Generates a key</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>mhash_keygen_s2k</function></funcdef> + <paramdef>int <parameter>hash</parameter></paramdef> + <paramdef>string <parameter>password</parameter></paramdef> + <paramdef>string <parameter>salt</parameter></paramdef> + <paramdef>int <parameter>bytes</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>Mhash_keygen_s2k</function> generates a key that is + <parameter>bytes</parameter> long, from a user given password. + This is the Salted S2K algorithm as specified in the OpenPGP + document (RFC 2440). That algorithm will use the specified + <parameter>hash</parameter> algorithm to create the key. + The <parameter>salt</parameter> must be different and random + enough for every key you generate in order to create different keys. + That salt must be known when you check the keys, thus it is + a good idea to append the key to it. Salt has a fixed length + of 8 bytes and will be padded with zeros if you supply less bytes. + Keep in mind that user supplied passwords are not really suitable + to be used as keys in cryptographic algorithms, since users normally + choose keys they can write on keyboard. These passwords use + only 6 to 7 bits per character (or less). It is highly recommended + to use some kind of tranformation (like this function) to the user + supplied key. + </para> </refsect1> </refentry> @@ -216,7 +288,7 @@ 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
« previous php.doc (#969333256) next »