did you set $config['encryption_key'] = "Test@123"; in config file
OR
you have to pass the key after string
$this->encrypt->encode(6, 'Test@123')
$this->encrypt->decode(6, 'Test@123')
i have extend the core library for this
create a file name MY_Encrypt.php with and put this file in application\libraries
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Encrypt extends CI_Encrypt
{
function encode($string, $key = "", $url_safe = TRUE) {
$ret = parent::encode($string, $key);
if ($url_safe) {
$ret = strtr($ret, array('+' => '.', '=' => '-', '/' => '~'));
}
return $ret;
}
function decode($string, $key = "") {
$string = strtr($string, array('.' => '+', '-' => '=', '~' => '/'));
return parent::decode($string, $key);
}
}
?>
Now you can use
$this->encrypt->encode(6)
$this->encrypt->decode(6)
this will have same result.