note 20856 added to function.mcrypt-get-iv-size

From: Date: Thu, 18 Apr 2002 20:46:53 +0000
Subject: note 20856 added to function.mcrypt-get-iv-size
Groups: php.notes 
Request: Send a blank email to php-notes+get-29537@lists.php.net to get a copy of this message
the above example, works, however I would like to share with you another example that derick at php.net helped me figure out: The IV needs to be the same size as the cipher/mode you are using. So we use substr() to achieve this. NOTE: This will fix your problems if you are trying to generate an IV and it is not working when you try to decrypt. The reason is that you must have the same IV (think: starting point) both at encryption and decryption stages. // create IV for CAST_256 in mode CFB // from the key (which is same in both en/decrypt stages $iv = substr(md5($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB)); cheers, kyle -- http://www.php.net/manual/en/function.mcrypt-get-iv-size.php http://master.php.net/manage/user-notes.php?action=edit+20856 http://master.php.net/manage/user-notes.php?action=delete+20856 http://master.php.net/manage/user-notes.php?action=reject+20856

« previous php.notes (#29537) next »