Fatal error: function call undefined mcrypt_encrypt ()

NOTE. Support for MCCR libraries depends on the fact that they have not been updated for years, and MCrypt should no longer be considered a viable or secure way to encrypt data. What's more, MCrypt is deprecated in PHP 5 and completely removed in PHP 7. If you have any code that runs MCrypt, you must reorganize it to use a more modern encryption library.




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

I skipped some steps, maybe any settings in PHP that I have to complete 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))); 
+49
php mcrypt
Apr 09 2018-10-09T00:
source share
16 answers

What worked for me with PHP version 5.2.8 was to open php.ini and enable the php_mcrypt.dll extension by deleting ; , i.e. by changing:

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

+28
Apr 09 '10 at 1:02
source share

If you recently upgraded to ubuntu 14.04, this is the fix for this problem:

 $ sudo mv /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/ $ sudo php5enmod mcrypt $ sudo service apache2 restart 
+80
May 29 '14 at 6:14
source share

For windows

 ;extension=php_mcrypt.dll to extension=php_mcrypt.dll then restart your apache server 

For redhat

 sudo yum install php55-mcrypt //if php5.5 sudo yum install php-mcrypt //if less than 5.4 sudo service httpd restart //if apache 2.4 sudo /etc/init.d/httpd restart //if apache 2.2 or less 

For ubuntu

 sudo apt-get install php5-mcrypt sudo service apache2 restart //if server not reloaded automatically 

If it doesn’t work yet

sudo php5enmod mcrypt && & sudo service apache2 restart

+23
Jan 09 '14 at 5:54 on
source share

You do not have the mcrypt library installed.

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

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




On OSX, you can easily install mcrypt via homebrew

 brew install php54-mcrypt --without-homebrew-php 

Then add this line to /etc/php.ini.

 extension="/usr/local/Cellar/php54-mcrypt/5.4.24/mcrypt.so" 
+18
Apr 09 2018-10-09T00:
source share

In Ubuntu, I had a problem and solved it with

 $ sudo apt-get install php5-mcrypt $ sudo service apache2 reload 
+11
Apr 08 '13 at 13:22
source share

On ubuntu 14.10:

Install mcrypt module

 sudo apt install php5-mcrypt 

Enable mcrypt module on apache2

 sudo a2enmod mcrypt 

Update module configuration

 sudo service apache2 restart 
+7
Nov 26 '14 at 13:21
source share

On Linux Mint 17.1 Rebecca - calling the undefined function mcrypt_create_iv ...

Solved by adding the following line in php.ini

 extension=mcrypt.so 

After that a

 service apache2 restart 

decided this ...

+5
Jun 12 '15 at 15:39
source share

Is mcrypt enabled? You can use phpinfo() to find out if this is.

+3
Apr 09 '10 at 0:55
source share

One more thing: if you are using PHP through a web server such as Apache, try restarting the web server. This will "reset" any PHP modules that may be present, activating the new configuration.

+3
Jun 24 2018-11-11T00:
source share

Assuming you are using debian linux (I am using Linux mint 12, the problem was on the Ubuntu 12.04.1 LTS server on which I was ssh'ed.)

I suggest taking @dkamins advice and make sure you have mcrypt installed and active when installing php5. Use "sudo apt-get install php5-mcrypt" to install. My notes are below.

Using the PHP version of PHP Version 5.3.10-1ubuntu3.4 , if you open phpinfo (), as suggested by @John Conde, what do you do by creating a test file on a web server (for example, create a testphp.php status page only with the content "" anywhere available on the server through the browser)

I did not find that the status is enabled or disabled on the status page when opening in the browser. When I then opened the php.ini file mentioned by @Anthony Forloney, thinking to uncomment ;extension=php_mcrypt.dll to extension=php_mcrypt.dll

I switched it back and forth and restarted Apache (I am running Apache2 and you can restart in my setup using sudo /etc/init.d/apache2 restart or when you are only sudo restart in this directory, I suppose) with the change and unchanged, but all do not go. I took @dkamins advice and went to install the package with "sudo apt-get install php5-mcrypt" and then restarted apache as above. Then my error went away and my application worked perfectly.

+3
Oct 19 '12 at 11:11
source share

If you are using php5-fpm, remember to restart it after installing mcrypt

restarting php5-fpm service

+3
Oct 12 '15 at 11:36
source share

If you are using ubuntu 14.04 here, fix this problem:

First check php5-mcryp already installed apt apt-get install php5-mcrypt

If installed, just run this two commands or install and run this two commands

 $ sudo php5enmod mcrypt $ sudo service apache2 restart 

I hope this works.

+3
May 20 '16 at 12:56
source share

I had the same problem for PHP 7 version of missing mcrypt.

It worked for me.

 sudo apt-get update sudo apt-get install mcrypt php7.0-mcrypt sudo apt-get upgrade sudo service apache2 restart (if needed) 
+3
Mar 23 '17 at 11:29
source share

for Linux (Fedora)

 yum -y install php-mcrypt 

Enable the module by adding: 'extension = mcrypt.so' in PHP.ini. (/etc/php.ini)

 systemctl restart httpd.service 

Done!

+1
Sep 14 '13 at 14:11
source share

For me, this helped remove mcrypt with:

 sudo apt-get purge php5-mcrypt 

and just reinstall it:

 sudo apt-get install php5-mcrypt 

and don't forget to restart apache as described above.

I don’t know why and how it was in my case (using vm with provided php55), but maybe this will help someone else. I also had a problem with some other modules like xcache ...

+1
Sep 08 '16 at 8:06
source share

Check and install php5-mcrypt:

 sudo apt-get install php5-mcrypt 
0
May 05 '15 at 20:54
source share



All Articles