Skip to content
Advertisement

codeigniter encryption / decryption function returns empty string

I am trying to login using codeigniter, but not able to do so. Then i tried to copy password from DB and pass it to dycription->decode() function, and it’s returning empty string.

Here is the code

var_dump($this->encryption->decode('s0xxxxxxXjrUxxxxxxBTxxxxhc'));

output was: string(0) “”

And this code also returning empty strings

$decoded_password = $this->encryption->decode($encoded_password); 
$decoded_username = $this->encryption->decode($encoded_username);

What i am doing wrong here?

UPDATE: i tried encrypting a string and PRINT IT then decrypt and PRINT, After encryption it returns NULL/Empty and after decryption it returns NULL/Empty (Obvious). Code is below

$encval = $this->encryption->encode('codeigniter');
echo $encval.'  --  IT WAS --'.'codeigniter';
echo "<br>---------------------------------------------------<br>";
echo $this->encryption->decode($encval);

OUTPUT: ^Nothing

Advertisement

Answer

Look, there are 2 ways to use encryption in CI and both should not be used for password(use hashing). First find out which one was used to encrypt the password and then stored in DB.Also, its possible some kind of KEY may have been used while encrypting the password check this too.

Below are the 2 encryption libs available in CI.

1.Encrypt class : https://www.codeigniter.com/user_guide/libraries/encrypt.html

2.Encryption Lib: https://www.codeigniter.com/user_guide/libraries/encryption.html

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement