note 119395 added to function.mcrypt-encrypt

From: Date: Fri, 27 May 2016 15:40:17 +0000
Subject: note 119395 added to function.mcrypt-encrypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-205596@lists.php.net to get a copy of this message
I always use this method to prevent a lot of errors function encrypt( $string ) { $algorithm = 'rijndael-128'; // You can use any of the available $key = md5( "mypassword", true); // bynary raw 16 byte dimension. $iv_length = mcrypt_get_iv_size( $algorithm, MCRYPT_MODE_CBC ); $iv = mcrypt_create_iv( $iv_length, MCRYPT_RAND ); $encrypted = mcrypt_encrypt( $algorithm, $key, $string, MCRYPT_MODE_CBC, $iv ); $result = base64_encode( $iv . $encrypted ); return $result; } function decrypt( $string ) { $algorithm = 'rijndael-128'; $key = md5( "mypassword", true ); $iv_length = mcrypt_get_iv_size( $algorithm, MCRYPT_MODE_CBC ); $string = base64_decode( $string ); $iv = substr( $string, 0, $iv_length ); $encrypted = substr( $string, $iv_length ); $result = mcrypt_decrypt( $algoritmo, $key, $encrypted, MCRYPT_MODE_CBC, $iv ); return $result; } ---- Server IP: 72.52.91.14 Probable Submitter: 80.207.172.194 ---- Manual Page -- http://php.net/manual/en/function.mcrypt-encrypt.php Edit -- https://master.php.net/note/edit/119395 Del: integrated -- https://master.php.net/note/delete/119395/integrated Del: useless -- https://master.php.net/note/delete/119395/useless Del: bad code -- https://master.php.net/note/delete/119395/bad+code Del: spam -- https://master.php.net/note/delete/119395/spam Del: non-english -- https://master.php.net/note/delete/119395/non-english Del: in docs -- https://master.php.net/note/delete/119395/in+docs Del: other reasons-- https://master.php.net/note/delete/119395 Reject -- https://master.php.net/note/reject/119395 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205596) next »