I am trying to use encryption library in Codeigniter 3.1.3 in HMVC provided by Wiredesignz. I even tried initializing the encryption library with my custom settings as below as it didn't work with default:
$this->load->library('encryption');
$this->encryption->initialize(
array(
'cipher' => 'aes-256',
'driver' => 'openssl',
'mode' => 'ctr'
)
);
$this->load->module('site_security');
$str = "12345";
$encrypted_str = $this->encryption->encrypt($str);
echo "encrypted_str: ".$encrypted_str; //works fine gives me encrypted string.
$decrypted_str = $this->encryption->decrypt($encrypted_str);
echo "<br>decrypted_str: ".$decrypted_str; // always gives me empty string
I used the encrypt method to successfully encrypt a string but I can't decrypt it, it always gives me empty string. I also set the $config['encryption_key'] to a 32 characters string in config/config.php file.