Home » Php » php – The Encrypt library requires the Mcrypt extension

php – The Encrypt library requires the Mcrypt extension

Posted by: admin July 12, 2020 Leave a comment


I have a PHP application written using the Codeigniter framework. When I am trying to run this application on Windows Machine then I am getting below error:

An Error Was Encountered
The Encrypt library requires the Mcrypt extension.

This same application working fine on some random Windows Machine having the same configuration. I have tried on 5 different windows 10 machines and got this error on 3 Machine and worked fine on 2 machines. Here I have used the same installer to install XAMPP on all the machines and the same code, but still don’t know how to make it run smoothly.
I have tried almost all the suggestions available online like to make a change in php.ini but no luck so far.

How to&Answers:

(FOR CI USERS only) If you are switched from CI2 XAMPP(php5) to XAMPP(php7) then, paste encrypt.php in CI->system->libraries folder, after this it should be fine !


For the future comers, I have face this problem too. It is usually issue with php 7.2.

Simply replace encrypt with encryption in autoload.php

$autoload['libraries'] = array('database', 'email', 'session', 'encrypt', 'pagination');

$autoload['libraries'] = array('database', 'email', 'session', '**encryption**', 'pagination');


To codeigniter developers: some CI releases do not have encrypt listed in autoload

$autoload['libraries'] = array();

Instead, they are loaded under CI_Controller derived controllers.

Search for


and replace with:



On Linux where PHP 5.6 or less…

apt-get install php5-mcrypt


Open php.ini

search for ;extension=php_mcrypt.dll

then remove ; infront of it to uncomment it.

save the php.ini file


Run the following code to check if the mccrypt is enabled in your PHP Settings.

<?php phpinfo(); ?>

By default, it is enabled on some server so that’s why it is working on the random machine.

The quickest method to enable php-mcrypt on windows server – all you need to do is:

  • Find php.ini (main php configuration file)

  • Open and search for;extension=php_mcrypt.dll )

  • Uncomment/remove “;” and save the php.ini


For Windows users

Autoload.php file will be as follows

$autoload[‘libraries’] = array(‘database’, ‘session’, ‘form_validation’, ‘encrypt’, ‘template’, ‘finediff’, ‘parser’);

From the above remove encryption like below, after that restart apache services then it will works….

$autoload[‘libraries’] = array(‘database’, ‘session’, ‘form_validation’, ‘template’, ‘finediff’, ‘parser’);


I was using PHP 7.2.xx version of php and followed the following steps:

Mcrypt PECL extenstion

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1

Update the ini file with these commands:

sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"

Verifying the installation:

php7.2-sp -i | grep mcrypt