tags:

views:

236

answers:

3

Does anyone know why this error message: (Call to undefined function mcrypt_encrypt() ) displays when I run the following code below?

Am I missing some steps perhaps any setting in PHP I have to do before this code can work?

$key = 'password to (en/de)crypt';
$string = 'string to be encrypted';

$test = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)));
A: 

Is mcrypt enabled? You can use phpinfo() to see if it is.

John Conde
+1  A: 

You don't have the mcrypt library installed.

See http://www.php.net/manual/en/mcrypt.setup.php for more information.

If you are on shared hosting, you can ask your provider to install it.

dkamins
+4  A: 

What had worked for me with PHP version 5.2.8, open up php.ini and allow the php_mycrypt.dll extension by removing the ;, i.e. changing:

;extension=php_mcrypt.dll to extension=php_mcrypt.dll

Anthony Forloney