Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php error: The Encrypt library requires the Mcrypt extension in codeigniter

I have a login and sign up form and use the encrypt library to encrypt the password.. I am using Xampp for my server and my system works correctly..

code to encrypt the password:

$this->encrypt->encode('my password'); 

add encrypt library

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

and setting the secret key in config:

$config['encryption_key'] = 'nmsc encrypt secret key';

My code works well using xampp server in windows but when Im trying to upload my website to ubuntu server I've got an error says

The Encrypt library requires the Mcrypt extension

how to fix that problem? refering this guide https://www.codeigniter.com/user_guide/libraries/encryption.html but I dont know how to install that mcrypt. my website needs to run from ubuntu server. how to install or fix that problem?

like image 985
MGB C Avatar asked Mar 04 '16 14:03

MGB C


People also ask

How do I enable PHP mcrypt extension?

You can install Mcrypt from the PHP Source Tree as a module if you choose. Enable the module by adding: 'extension=mcrypt.so' to PHP. ini. Done!

What is mcrypt PHP extension required?

What is mcrypt? The mcrypt extension is a replacement for the UNIX crypt command. These commands serve as a means to encrypt files on UNIX and Linux systems. The php-mcrypt extension serves as an interface between PHP and mcrypt.

How do I know if PHP mcrypt is installed?

You can also achieve this same screen by viewing a php file that has: phpinfo(); somewhere in the code. In this screen, simply search for the string "mcrypt support". If installed, you will see a box that says "enabled".


2 Answers

Best solution is (only available for CI 3 and up):

change

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

to

 $this->load->library('encryption');
like image 83
Aditya Tomar Avatar answered Oct 09 '22 11:10

Aditya Tomar


You should install the PHP mcrypt module;

sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt

And normally you will be good ;)

like image 42
Wajih OUERIEMI Avatar answered Oct 09 '22 10:10

Wajih OUERIEMI