CodeIgniter Forums
Setting a default cipher - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Setting a default cipher (/showthread.php?tid=45968)



Setting a default cipher - El Forum - 10-12-2011

[eluser]silentday[/eluser]
Ran into an issue with setting $config['sess_encrypt_cookie']= TRUE; and then trying to set set_cipher(MCRYPT_BLOWFISH) in a controller that handles some data encryption.

Session.php
Code:
if ($this->sess_encrypt_cookie == TRUE)
  {
   $cookie_data = $this->CI->encrypt->encode($cookie_data);
  }


It would appear that once the site loads up the cookie is encrypted using the default cipher, but once my controller sets the cipher it can no longer read the cookie data since the cookie data was created with a different cipher.

What is the best way to set the default cipher to use MCRYPT_BLOWFISH. I thought of trying to overload the _get_cipher() method which sets the default cipher:
Code:
function _get_cipher()
{
  if ($this->_mcrypt_cipher == '')
  {
   $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
  }

  return $this->_mcrypt_cipher;
}

Please let me know of your thoughts on the best approach.