8

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.

Sohail Ahmad
  • 7,309
  • 5
  • 27
  • 46
  • So, install (or enable) the extension. This is something you should have googled about. – tereško May 26 '18 at 10:05
  • 4
    Be aware that mcrypt was ***DEPRECEATED*** in version 7.1 of PHP and has been ***REMOVED*** from version 7.2 of PHP – SpacePhoenix May 26 '18 at 10:26
  • I am using PHP Version 7.2.4 if possible could you please suggest the workaround to solve it – Rahul Kumar Singh May 26 '18 at 10:37
  • Possible duplicate of [php error: The Encrypt library requires the Mcrypt extension in codeigniter](https://stackoverflow.com/questions/35798048/php-error-the-encrypt-library-requires-the-mcrypt-extension-in-codeigniter) – kunal shaktawat Nov 27 '19 at 17:11

12 Answers12

15

(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 !

Pushpendra Kumar
  • 1,721
  • 1
  • 15
  • 21
  • It works also for non-XAMPP configurations, but I did not copy the file but based on it I made the appropriate corrections on the side of my application. – Grzegorz Adam Kowalski Mar 01 '19 at 12:25
  • This has worked but I could not tell what you changed because this file exists in the folder. Just replaced its content. – Neri Jul 10 '19 at 11:47
11

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');
Javier C.
  • 7,859
  • 5
  • 41
  • 53
Abhishek Soni
  • 563
  • 1
  • 6
  • 17
4

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

$this->load->library('encrypt');

and replace with:

$this->load->library('encryption');
Anatoliy R
  • 1,749
  • 2
  • 14
  • 20
0

On Linux where PHP 5.6 or less...

apt-get install php5-mcrypt

Bira
  • 4,531
  • 2
  • 27
  • 42
0

After replace Encrypt.php's Pushpendra Kumar, don't forget to set :
$config['encryption_key'] = 'encryption_key';

Khamad Ali
  • 33
  • 1
  • 11
0

INstall extention from here https://pecl.php.net/package/mcrypt/1.0.3/windows

use TS version ..

put php_mcrypt.dll file into ../php/ext/

topimiring
  • 140
  • 1
  • 8
0

you can bypass mbstring by just disabling

$config['sess_encrypt_cookie'] = TRUE;

in config.php file.

F. Müller
  • 3,969
  • 8
  • 38
  • 49
Aminnazir
  • 1
  • 1
-1

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

pspatel
  • 508
  • 2
  • 7
  • 18
-1

Open php.ini

search for ;extension=php_mcrypt.dll

then remove ; infront of it to uncomment it.

save the php.ini file

spoofie
  • 103
  • 7
-1

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');

  • This doesn't solve the problem since you just removed the encryption libraries from the $autoload[libraries] array – Charles Jan 06 '19 at 17:42
-1

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
Shashank Saxena
  • 2,014
  • 17
  • 11
-1

This is the result of the deprecation of Mycrypt extension. If you are using PHP > 7.1 and you need it you can follow the guidelines on this link Add mycrypt extension after PHP 7.1

Content from github link:

1-First, you should download the suitable version for your system from here: https://pecl.php.net/package/mcrypt/1.0.3/windows

2-Later, you should copy php_mcrypt.dll under ../xampp/php/ext/

3-you should enable extension like extension=mcrypt from xampp/php/php.ini

personly I modified the php.ini file and i add this lines :

extension=imap extension=mcrypt

of course, these two lines have the 3 dll file saved on ../xampp/php/ext/ as :

php_imap.dll php_mcrypt.dll

jsims281
  • 2,206
  • 2
  • 30
  • 57
NgaizaJr
  • 1
  • 1