• Register

The function mcrypt_get_iv_size () is deprecated in the updated versions of php like php 7. When you try to use this function with php latest version it will show warning that this function is depreciated in the newer version of php.

Mcrypt_get_iv_size () function in php

Mcrypt_get_iv_size () function is used to return the Initialization Vector belonging of a specific cipher/mode combination.  This function is more useful as it uses the resources returned by myceypt_module_open().

How mcrypt_get_iv_size () function works:


mcrypt_get_iv_size ( cipher , mode )

This function accepts two parameters as input and returns the desired results. These parameters are cipher and “cipher and mode”.

Parameters and return value

Cipher:  Cipher parameter is constant that belongs to the MYCEYPT_ciphername, or it may be the name of the algorithm in the form of string.

Mode:  Mode parameter is either the constant that belongs to the MYCRYPT_MODE_modename, or the it could be one of the following strings ( "ecb",  "nofb”, “cbc", "cfb", "ofb", or a  "stream"). ECB does not require the IV mode and ignores it.  To make the encryption and decryption successful its recommended that you should use the same Initialization vector.

Return value:  This function has a return type; it returns the size of the initialization vector IV in number of bytes.  If the input is not correct or an error occurs it returns the false. if the Initialization vector is ignored it will return a zero value.


    echo mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_OFB) . "<BR>";

    echo mcrypt_get_iv_size('des', 'CBC') . "<BR>";

Note: This function is depreciated in update version of PHP 7.01 and it will be removed from php 7.2.0 , You need to upgrade the php version. And you can also enable or add mycrypt extension library.


7,490 points
10 5 2