Codeigniter Password Decryption

Russ Toms picture Russ Toms · Feb 2, 2015 · Viewed 21.3k times · Source

I am currently trying to import a user list from a previous database that has encrypted passwords using codeIgniter's Mcrypt protocol.

Quite frankly, I have no idea what I'm doing :( I've installed the framework on my server, and have attempted to call the decrypt class from the framework, and it's simply not taking.

My objective is to decrypt the passwords and encrypt them into Joomla's (what I think is used, at least) md5 encrypted and salted passwords. Here is an example of a password that I need to be decrypted:

r5WEX++ZKggg7d6fQYAZfFOm/z3nTJmxQA00zVWhhn7cvmrSrIm/NYI51o9372qf6JtYQEil72b4JzszVo+oPg==

I think I can handle the re-encryption, I just have no idea how to decrypt these things. Thank you to anyone that can help!

Answer

Mehdi Maghrouni picture Mehdi Maghrouni · Feb 3, 2015

Codeigniter by default uses $config['encryption_key'] which you can find it in config file, for cryptographic process !

so for decrypting it , you have to first have this key ! then you can decrypt it as follows :

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

$encrypted_password = 'r5WEX++ZKggg7d6fQYAZfFOm/z3nTJmxQA00zVWhhn7cvmrSrIm/NYI51o9372qf6JtYQEil72b4JzszVo+oPg==';
$key = 'secret-key-in-config';

$decrypted_string = $this->encrypt->decode($encrypted_password, $key);

and after that you can encrypt it again !