mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 00:12:06 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@306418 c90b9560-bf6c-de11-be94-00142212c4b1
142 lines
4.0 KiB
XML
142 lines
4.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 4a5d31d554bd9208d62867842522926e67639705 Maintainer: x1v4nx Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<refentry xml:id="function.mdecrypt-generic" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>mdecrypt_generic</refname>
|
|
<refpurpose>Desencripta datos</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>mdecrypt_generic</methodname>
|
|
<methodparam><type>resource</type><parameter>td</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>data</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Esta función desencripta datos. Note que la longitud de la cadena retornada
|
|
puede ser mayor a la cadena no cifrada, debido al relleno de la
|
|
información.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>td</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Un descriptor de cifrado devuelto por
|
|
<function>mcrypt_module_open</function>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>data</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Los datos encriptados.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>mdecrypt_generic</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
/* Data */
|
|
$key = 'esta es una clave muy larga, aún para el cifrador';
|
|
$plain_text = 'información muy importante';
|
|
|
|
/* Apertura de un modo, y creación de un IV */
|
|
$td = mcrypt_module_open('des', '', 'ecb', '');
|
|
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
|
|
$iv_size = mcrypt_enc_get_iv_size($td);
|
|
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
|
|
|
|
/* Iniciando gestor de encriptación */
|
|
if (mcrypt_generic_init($td, $key, $iv) != -1) {
|
|
|
|
/* Encriptación de los datos */
|
|
$c_t = mcrypt_generic($td, $plain_text);
|
|
mcrypt_generic_deinit($td);
|
|
|
|
/* Reinicialización de los buffers para desencriptación */
|
|
mcrypt_generic_init($td, $key, $iv);
|
|
$p_t = mdecrypt_generic($td, $c_t);
|
|
|
|
/* Finalización */
|
|
mcrypt_generic_deinit($td);
|
|
mcrypt_module_close($td);
|
|
}
|
|
|
|
if (strncmp($p_t, $plain_text, strlen($plain_text)) == 0) {
|
|
echo "ok\n";
|
|
} else {
|
|
echo "error\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
El ejemplo anterior muestra cómo chequear si los datos antes del cifrado
|
|
son los mismos después de la decriptación. Es muy importante reinicializar
|
|
el buffer de cifrado con <function>mcrypt_generic_init</function> antes
|
|
de intentar descifrar los datos.
|
|
</para>
|
|
<para>
|
|
El identificador de descifrado debería siempre ser inicializado con
|
|
<function>mcrypt_generic_init</function> con una clave y un IV antes
|
|
de invocar a esta función. Cuando el cifrado haya terminado, se debería
|
|
liberar los buffers de cifrado al invocar a <function>mcrypt_generic_deinit</function>
|
|
Véase <function>mcrypt_module_open</function> para un ejemplo.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>mcrypt_generic</function></member>
|
|
<member><function>mcrypt_generic_init</function></member>
|
|
<member><function>mcrypt_generic_deinit</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- 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
|
|
-->
|