File: reference.xml

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (197 lines) | stat: -rw-r--r-- 8,792 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.16 $ -->
<!-- Purpose: mathcrypto.crypto -->
<!-- Membership: bundled, external -->

 <reference id="ref.mcrypt">
  <title>Mcrypt Encryption Functions</title>
  <titleabbrev>mcrypt</titleabbrev>
  
  <partintro>
   <section id="mcrypt.intro">
    &reftitle.intro;
    <para>
     This is an interface to the mcrypt library, which supports a wide
     variety of block algorithms such as DES, TripleDES, Blowfish
     (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and
     GOST in CBC, OFB, CFB and ECB cipher modes. Additionally, it
     supports RC6 and IDEA which are considered "non-free".
    </para>
   </section>

   <section id="mcrypt.requirements">
    &reftitle.required;
    <para>
     These functions work using <ulink url="&url.mcrypt;">mcrypt</ulink>.
     To use it, download <filename>libmcrypt-x.x.tar.gz</filename> from <ulink
     url="&url.mcrypt;">&url.mcrypt;</ulink> and follow the included
     installation instructions.  Windows users will find all the
     needed compiled mcrypt binaries at
     <ulink url="&url.mcrypt.windows;">&url.mcrypt.windows;</ulink>.
    </para>
    <simpara>
     As of PHP 5.0.0 you will need libmcrypt Version 2.5.6 or greater.
    </simpara>
    <para>
     If you linked against libmcrypt 2.4.x or higher, the following additional
     block algorithms are supported: CAST, LOKI97, RIJNDAEL, SAFERPLUS,
     SERPENT and the following stream ciphers: ENIGMA (crypt), PANAMA, RC4 and
     WAKE. With libmcrypt 2.4.x or higher another cipher mode is also
     available; nOFB.
    </para>
   </section>

   &reference.mcrypt.configure;

   &reference.mcrypt.ini;

   <section id="mcrypt.resources">
    &reftitle.resources;
    &no.resource;
   </section>

   &reference.mcrypt.constants;
   
   <section id="mcrypt.ciphers">
    <title>Mcrypt ciphers</title>
    <para>
     Here is a list of ciphers which are currently supported by the mcrypt
     extension.  For a complete list of supported ciphers, see the defines at
     the end of <filename>mcrypt.h</filename>. The general rule with the
     mcrypt-2.2.x API is that you can access the cipher from PHP with
     MCRYPT_ciphername. With the libmcrypt-2.4.x and libmcrypt-2.5.x API these constants also work,
     but it is possible to specify the name of the cipher as a string with a
     call to <function>mcrypt_module_open</function>.
     <itemizedlist>
      <listitem><simpara>MCRYPT_3DES</simpara></listitem>
      <listitem><simpara>MCRYPT_ARCFOUR_IV (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_ARCFOUR (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_BLOWFISH</simpara></listitem>
      <listitem><simpara>MCRYPT_CAST_128</simpara></listitem>
      <listitem><simpara>MCRYPT_CAST_256</simpara></listitem>
      <listitem><simpara>MCRYPT_CRYPT</simpara></listitem>
      <listitem><simpara>MCRYPT_DES</simpara></listitem>
      <listitem><simpara>MCRYPT_DES_COMPAT (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_ENIGMA (libmcrypt > 2.4.x only, alias for MCRYPT_CRYPT)</simpara></listitem>
      <listitem><simpara>MCRYPT_GOST</simpara></listitem>
      <listitem><simpara>MCRYPT_IDEA (non-free)</simpara></listitem>
      <listitem><simpara>MCRYPT_LOKI97 (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_MARS (libmcrypt > 2.4.x only, non-free)</simpara></listitem>
      <listitem><simpara>MCRYPT_PANAMA (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RIJNDAEL_128 (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RIJNDAEL_192 (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RIJNDAEL_256 (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RC2</simpara></listitem>
      <listitem><simpara>MCRYPT_RC4 (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RC6 (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RC6_128 (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RC6_192 (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_RC6_256 (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_SAFER64</simpara></listitem>
      <listitem><simpara>MCRYPT_SAFER128</simpara></listitem>
      <listitem><simpara>MCRYPT_SAFERPLUS (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_SERPENT(libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_SERPENT_128 (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_SERPENT_192 (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_SERPENT_256 (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_SKIPJACK (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_TEAN (libmcrypt 2.2.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_THREEWAY</simpara></listitem>
      <listitem><simpara>MCRYPT_TRIPLEDES (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_TWOFISH (for older mcrypt 2.x versions, or mcrypt > 2.4.x )</simpara></listitem>
      <listitem><simpara>MCRYPT_TWOFISH128 (TWOFISHxxx are available in newer 2.x versions, but not in the 2.4.x versions)</simpara></listitem>
      <listitem><simpara>MCRYPT_TWOFISH192</simpara></listitem>
      <listitem><simpara>MCRYPT_TWOFISH256</simpara></listitem>
      <listitem><simpara>MCRYPT_WAKE (libmcrypt > 2.4.x only)</simpara></listitem>
      <listitem><simpara>MCRYPT_XTEA (libmcrypt > 2.4.x only)</simpara></listitem>
     </itemizedlist>
    </para>
    <para>
     You must (in CFB and OFB mode) or can (in CBC mode) supply an
     initialization vector (IV) to the respective cipher function. The
     IV must be unique and must be the same when
     decrypting/encrypting. With data which is stored encrypted, you
     can take the output of a function of the index under which the
     data is stored (e.g.  the MD5 key of the filename).
     Alternatively, you can transmit the IV together with the encrypted
     data (see chapter 9.3 of &book.applied.cryptography; for a
     discussion of this topic).
    </para>
   </section>
   
   <section id="mcrypt.examples">
    &reftitle.examples;
    <para>
     Mcrypt can be used to encrypt and decrypt using the above
     mentioned ciphers. If you linked against libmcrypt-2.2.x, the
     four important mcrypt commands (<function>mcrypt_cfb</function>,
     <function>mcrypt_cbc</function>, <function>mcrypt_ecb</function>,
     and <function>mcrypt_ofb</function>) can operate in both modes
     which are named MCRYPT_ENCRYPT and MCRYPT_DECRYPT, respectively.
     <example>
      <title>Encrypt an input value with TripleDES under 2.2.x in ECB mode</title>
      <programlisting role="php">
<![CDATA[
<?php
$key = "this is a secret key";
$input = "Let us meet at 9 o'clock at the secret place.";

$encrypted_data = mcrypt_ecb (MCRYPT_3DES, $key, $input, MCRYPT_ENCRYPT);
?>
]]>
      </programlisting>
     </example>
     This example will give you the encrypted data as a string in
     <literal>$encrypted_data</literal>.
    </para>
    <para>
     If you linked against libmcrypt 2.4.x or 2.5.x, these functions are still
     available, but it is recommended that you use the advanced functions.
     <example>
      <title>Encrypt an input value with TripleDES under 2.4.x and higher in ECB mode</title>
      <programlisting role="php">
<![CDATA[
<?php
    $key = "this is a secret key";
    $input = "Let us meet at 9 o'clock at the secret place.";

    $td = mcrypt_module_open('tripledes', '', 'ecb', '');
    $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
    mcrypt_generic_init($td, $key, $iv);
    $encrypted_data = mcrypt_generic($td, $input);
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
?>
]]>
      </programlisting>
     </example>
     This example will give you the encrypted data as a string in
     <literal>$encrypted_data</literal>.  For a full example see
     <function>mcrypt_module_open</function>.
    </para>
   </section>
  </partintro>

&reference.mcrypt.functions;

 </reference> 
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->