Say I have this set up as my encryption key and I already have the encrypt library on autoload:
$config['encryption_key'] = 'bjA{<ATCs1w5?,8N(bJvgO3CW_<]t?@o';
How do I use it in an encrypt function?
function s()
{
$something = $this->encrypt->encode('eoaighaeg',$key);
echo $this->encrypt->decode($something, $key);
}
^ Non working example to give you an idea.
According to this documentation, http://codeigniter.com/nightly_user_guide/libraries/encryption.html
If you didn't supply any key parameter for $this->encrypt->encode() function, it automatically use config encryption key.
$this->encrypt->encode($msg);
You don't. CI already does that, as you can read on the manual
If you want to pass a custom key, different from that one used in the config file, you need to specify it first:
$msg = 'Message';
$key = 'bjA{<ATCs1w5?,8N(bJv';
$encrypted_string = $this->encrypt->encode($msg, $key);
But that works only locally, otherwise you just use
$this->encrypt->encode($msg)
and CI applies the default one.
As with decoding it goes the same way, you don't specify the key if you use the default key, else pass your custom one as second parameter of $this->encrypt->decode()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With