CodeIgniter Forums
Setting a default cipher - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Setting a default cipher (/showthread.php?tid=45968)

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

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.

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:
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.