svn: /phpdoc/en/trunk/reference/mcrypt/ examples.xml

From: Date: Fri, 15 May 2015 15:07:23 +0000
Subject: svn: /phpdoc/en/trunk/reference/mcrypt/ examples.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13302@lists.php.net to get a copy of this message
ircmaxell Fri, 15 May 2015 15:07:23 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=336782 Log: Clean up example for mcrypt. Thanks Scott Arciszewski Changed paths: U phpdoc/en/trunk/reference/mcrypt/examples.xml Modified: phpdoc/en/trunk/reference/mcrypt/examples.xml =================================================================== --- phpdoc/en/trunk/reference/mcrypt/examples.xml 2015-05-15 12:50:18 UTC (rev 336781) +++ phpdoc/en/trunk/reference/mcrypt/examples.xml 2015-05-15 15:07:23 UTC (rev 336782) @@ -16,15 +16,15 @@ 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 <literal>TripleDES</literal> under 2.4.x and higher in <literal>ECB</literal> mode</title> + <title>Encrypt an input value with <literal>AES</literal> with a 256-bit key under 2.4.x and higher in <literal>CBC</literal> mode</title> <programlisting role="php"> <![CDATA[ <?php - $key = "this is a secret key"; + $key = hash('sha256', 'this is a secret key', true); $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); + + $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);

« previous php.doc.cvs (#13302) next »