The Encrypt library requires the Mcrypt extension
Asked Answered
W

11

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.

Wakeup answered 26/5, 2018 at 10:4 Comment(4)
So, install (or enable) the extension. This is something you should have googled about.Fiorenza
Be aware that mcrypt was DEPRECEATED in version 7.1 of PHP and has been REMOVED from version 7.2 of PHPParamaribo
I am using PHP Version 7.2.4 if possible could you please suggest the workaround to solve itWakeup
Possible duplicate of php error: The Encrypt library requires the Mcrypt extension in codeigniterPolyploid
B
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 !

Bobine answered 23/1, 2019 at 19:24 Comment(2)
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.Prowler
This has worked but I could not tell what you changed because this file exists in the folder. Just replaced its content.Colorful
H
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');
Handiwork answered 14/2, 2019 at 7:20 Comment(0)
T
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');
Tonsillectomy answered 9/4, 2020 at 9:2 Comment(0)
H
0

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

Hardspun answered 26/5, 2018 at 10:13 Comment(4)
mccrypt is not enabled on the machine where i am getting error. So, do i need to enable it ? if so then how ?Wakeup
Could you please give me the steps to make it enableWakeup
If you have access to the php.ini file you should be able to enable it. you probably have to uncomment a line within the php.ini refering to it by removing the ; before that line.Sponson
@RahulKumarSingh Updated answer for enabling extension.Hardspun
D
0

On Linux where PHP 5.6 or less...

apt-get install php5-mcrypt

Durning answered 10/7, 2018 at 1:43 Comment(0)
S
0

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

Sharecropper answered 2/8, 2020 at 6:44 Comment(0)
V
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/

Vat answered 5/2, 2021 at 2:51 Comment(0)
L
0

you can bypass mbstring by just disabling

$config['sess_encrypt_cookie'] = TRUE;

in config.php file.

Lingerfelt answered 3/2, 2023 at 7:24 Comment(0)
N
-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');

Nazarius answered 3/8, 2018 at 7:2 Comment(1)
This doesn't solve the problem since you just removed the encryption libraries from the $autoload[libraries] arrayNeodymium
U
-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
Ungracious answered 21/10, 2019 at 9:20 Comment(0)
I
-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

Incult answered 14/7, 2020 at 12:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.