<!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 defined 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 a block cipher mode that is generally unsuitable for most purposes. The use of this mode is not recommended. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_CBC</code></strong> (<em>cipher block chaining</em>) is a block cipher mode that is significantly more secure than <em>ECB</em> mode. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_CFB</code></strong> (<em>cipher feedback, in 8-bit mode</em>) is a stream cipher mode. It is recommended to use <em>NCFB</em> mode rather than <em>CFB</em> mode. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_OFB</code></strong> (<em>output feedback, in 8-bit mode</em>) is a stream cipher mode comparable to <em>CFB</em>, but can be used in applications where error propagation cannot be tolerated. It is recommended to use <em>NOFB</em> mode rather than <em>OFB</em> mode. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>MCRYPT_MODE_NOFB</code></strong> (<em>output feedback, in n-bit mode</em>) is comparable to <em>OFB</em> mode, but operates on the full 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"> Mcrypt supports some other modes of operation for which there are no predefined constants. They can be utilised by passing a string in place of the missing constants. <ul class="itemizedlist"> <li class="listitem"> <span class="simpara"> <strong><code>"ctr"</code></strong> (<em>counter mode</em>) is a stream cipher mode. </span> </li> <li class="listitem"> <span class="simpara"> <strong><code>"ncfb"</code></strong> (<em>cipher feedback, in n-bit mode</em>) is comparable to <em>CFB</em> mode, but operates on the full block size of the algorithm. </span> </li> </ul> </p> <p class="para"> Some other mode and random device constants: <dl> <dt id="constant.mcrypt-encrypt"> <strong><code>MCRYPT_ENCRYPT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </dt> <dd> <span class="simpara"> </span> </dd> <dt id="constant.mcrypt-decrypt"> <strong><code>MCRYPT_DECRYPT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </dt> <dd> <span class="simpara"> </span> </dd> <dt id="constant.mcrypt-dev-random"> <strong><code>MCRYPT_DEV_RANDOM</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </dt> <dd> <span class="simpara"> </span> </dd> <dt id="constant.mcrypt-dev-urandom"> <strong><code>MCRYPT_DEV_URANDOM</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </dt> <dd> <span class="simpara"> </span> </dd> <dt id="constant.mcrypt-rand"> <strong><code>MCRYPT_RAND</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </dt> <dd> <span class="simpara"> </span> </dd> </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>