Home » » mcrypt_generic_init

mcrypt_generic_init

Written By 1 on Monday, October 1, 2012 | 6:19 PM

int mcrypt_generic_init ( resource $td , string $key , string $iv )
This function initializes all buffers needed for encryption
You need to call this function before every call to mcrypt_generic() or mdecrypt_generic().


If you write error-checking into your code, be warned that this function returns FALSE on some errors, and 0 on success, hence
Following is the example
 
mcrypt_generic_init( $a, $b, $c ) or die( "Oops");
ALWAYS exits with the error message "Oops", and
(mcrypt_generic_init( $a, $b, $c ) >= 0 ) or die( "Oops");
Sometimes continues when mcrypt_generic_init() actually failed.
To check for successful init use something like:
$s = mcrypt_generic_init( $a, $b, $c );
if( ($s < 0) || ($s === false))
die( "error" );



0 Comment:

Post a Comment