mirror of
https://github.com/php/doc-fr.git
synced 2026-03-24 15:12:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@343371 c90b9560-bf6c-de11-be94-00142212c4b1
66 lines
2.2 KiB
XML
66 lines
2.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: be2383c6f9525dfc90b95764c7320edb501b7091 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
|
|
<appendix xml:id="mcrypt.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
&reftitle.examples;
|
|
<para>
|
|
Mcrypt permet de chiffrer et de déchiffrer en utilisant les méthodes
|
|
mentionnées ci-dessus. Si vous utilisez <literal>libmcrypt-2.2.x</literal>,
|
|
les 4 commandes importantes
|
|
(<function>mcrypt_cfb</function>, <function>mcrypt_cbc</function>,
|
|
<function>mcrypt_ecb</function> et <function>mcrypt_ofb</function>)
|
|
peuvent toutes opérer en mode <constant>MCRYPT_ENCRYPT</constant> et
|
|
<constant>MCRYPT_DECRYPT</constant>.
|
|
</para>
|
|
<para>
|
|
Si vous avez compilé PHP avec libmcrypt 2.4.x ou 2.5.x, ces fonctions sont toujours
|
|
disponibles, mais il est vivement conseillé d'utiliser les nouvelles
|
|
fonctions avancées.
|
|
<example>
|
|
<title>Chiffrement d'une valeur avec <literal>AES</literal> avec une clé 256-bit
|
|
sous 2.4.x et supérieur, en mode <literal>CBC</literal></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$key = hash('sha256', 'this is a secret key', true);
|
|
$input = "Rendez-vous à 9 heures, dans notre planque.";
|
|
|
|
$td = mcrypt_module_open('rijndael-128', '', 'cbc', '');
|
|
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_URANDOM);
|
|
mcrypt_generic_init($td, $key, $iv);
|
|
$encrypted_data = mcrypt_generic($td, $input);
|
|
mcrypt_generic_deinit($td);
|
|
mcrypt_module_close($td);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
Cet exemple va retourner les données chiffrées dans la variable
|
|
<literal>$encrypted_data</literal>. Pour un exemple complet,
|
|
voyez <function>mcrypt_module_open</function>.
|
|
</para>
|
|
</appendix>
|
|
|
|
<!-- 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:"~/.phpdoc/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
|
|
-->
|