AES and CBC in PHP

Posted by Kane on Stack Overflow See other posts from Stack Overflow or by Kane
Published on 2014-05-27T08:59:58Z Indexed on 2014/05/27 9:25 UTC
Read the original article Hit count: 170

Filed under:
|
|

I am trying to encrypt a string in php using AES-128 and CBC, but when I call mcrypt_generic_init() it returns false.

$cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '',MCRYPT_MODE_CBC, '');
$iv_size = mcrypt_enc_get_iv_size($cipher);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);

$res = mcrypt_generic_init($cipher, 'aaaa', $iv); //'aaaa' is a test key

Can someone tell me why is returning 0/false? I read the php documentation and seems correct (http://us.php.net/manual/en/mcrypt.examples.php)

© Stack Overflow or respective owner

Related posts about php

Related posts about encryption