<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Predefined Constants</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mcrypt.resources.html">Resource Types</a></div> <div class="next" style="text-align: right; float: right;"><a href="mcrypt.ciphers.html">Mcrypt ciphers</a></div> <div class="up"><a href="book.mcrypt.html">Mcrypt</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mcrypt.constants" class="appendix"> <h1>Predefined Constants</h1> <p class="simpara"> The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. </p> <p class="para"> Mcrypt can operate in four block cipher modes (<em>CBC</em>, <em>OFB</em>, <em>CFB</em>, and <em>ECB</em>). If linked against libmcrypt-2.4.x or higher the functions can also operate in the block cipher mode <em>nOFB</em> and in <em>STREAM</em> mode. Below you find a list with all supported encryption modes together with the constants that are defines for the encryption mode. For a more complete reference and discussion see Applied Cryptography by Schneier (ISBN 0-471-11709-9). <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_ECB</code></strong> (<em>electronic codebook</em>) is suitable for random data, such as encrypting other keys. Since data there is short and random, the disadvantages of ECB have a favorable negative effect. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_CBC</code></strong> (<em>cipher block chaining</em>) is especially suitable for encrypting files where the security is increased over <em>ECB</em> significantly. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_CFB</code></strong> (<em>cipher feedback</em>) is the best mode for encrypting byte streams where single bytes must be encrypted. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_OFB</code></strong> (<em>output feedback, in 8bit</em>) is comparable to <em>CFB</em>, but can be used in applications where error propagation cannot be tolerated. It's insecure (because it operates in 8bit mode) so it is not recommended to use it. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_NOFB</code></strong> (<em>output feedback, in nbit</em>) is comparable to OFB, but more secure because it operates on the block size of the algorithm. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_STREAM</code></strong> is an extra mode to include some stream algorithms like <em>"WAKE"</em> or <em>"RC4"</em>. </span> </li> </ul> </p> <p class="para"> Some other mode and random device constants: <dl> <dt id="constant.mcrypt-encrypt"> <span class="term"> <strong><code>MCRYPT_ENCRYPT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> </span> </dd> </dt> <dt id="constant.mcrypt-decrypt"> <span class="term"> <strong><code>MCRYPT_DECRYPT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> </span> </dd> </dt> <dt id="constant.mcrypt-dev-random"> <span class="term"> <strong><code>MCRYPT_DEV_RANDOM</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> </span> </dd> </dt> <dt id="constant.mcrypt-dev-urandom"> <span class="term"> <strong><code>MCRYPT_DEV_URANDOM</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> </span> </dd> </dt> <dt id="constant.mcrypt-rand"> <span class="term"> <strong><code>MCRYPT_RAND</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> </span> </dd> </dt> </dl> </p> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mcrypt.resources.html">Resource Types</a></div> <div class="next" style="text-align: right; float: right;"><a href="mcrypt.ciphers.html">Mcrypt ciphers</a></div> <div class="up"><a href="book.mcrypt.html">Mcrypt</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>