Welcome Guest, Not a member yet? Register   Sign In
Conflict between encrypt->set_cipher(MCRYPT_BLOWFISH); and session.php
#1

[eluser]minttux[/eluser]
hi bodies
i need somewhere in my website to call a library (that it called on header of each page)
that in that library inside the __construct() function i load encrypt class and also i need to call set_cipher(MCRYPT_BLOWFISH); to get short part of encoding so total lines in __construct() are:
Code:
public function __construct()
        {
          $this->CI =& get_instance();
          $this->CI->load->library('encrypt');
          $this->CI->encrypt->set_cipher(MCRYPT_BLOWFISH);
          $this->_get_list_excited_libs();
        }

then on other functions in bottom of layers inside that library i call encrypt class like this:
Code:
private function _get_list_excited_libs(){
         ...
          $libs[]=$this->CI->encrypt->decode(base64_decode($value));

        ...
        }
also another where i have:
Code:
private function _generate_encrypt_name($name){
    return base64_encode($this->CI->encrypt->encode($name));
        }

and all of this is for using in naming some files
if i don't use base64_encode it has forbidden characters and os prevent to create files with that names
and if i don't use set_cipher(MCRYPT_BLOWFISH); my names are very long
so both of these codes works correctly

but problem is when i use session on login page and everywhere i work with session i got this error:
Message: unserialize(): Error at offset 0 of 602 bytes

but when i comment this line on above code:
Code:
public function __construct()
        {
          $this->CI =& get_instance();
          $this->CI->load->library('encrypt');
          #$this->CI->encrypt->set_cipher(MCRYPT_BLOWFISH);
          $this->_get_list_excited_libs();
        }
the problem solved that i think there is conflict between this function and maybe same function inside session.php

so how can i fix this conflict ?
#2

[eluser]minttux[/eluser]
also session library placed in autoload that means i can remove this line from __construct() function:
$this->CI->load->library('encrypt');

now how can i remove conflict ?
#3

[eluser]minttux[/eluser]
up
#4

[eluser]minttux[/eluser]
:ohh:
my problem happened again Sad
i think this problem related to load twice this line:
Code:
$this->CI->encrypt->set_cipher(MCRYPT_BLOWFISH);

because it is inside __construct() function
and my page twice refresh

also it prevents to store something in cookies

what's your suggestion ?
#5

[eluser]minttux[/eluser]
woww encrypt class works with cookie ?

i disable $config['sess_encrypt_cookie'] and now encrypt class doesn't work anymore
i just make encrypt names for my file names
#6

[eluser]minttux[/eluser]
Finally i wrote my own encryption library that works same CI encryption class but doesn't conflict with Session.php and no Message: unserialize(): Error at offset 0 of 602 bytes error anymore

also it doesn't need to enable $config['sess_encrypt_cookie'] = True; in config file and works Independence
also it has two mod default mode that works same CI does
and safe mode for generate encryption string that can be store on filesystem as filename without forbidden characters (for all OS) also it has characters table that you can define forbidden characters to prevent create generation with that characters

if it is useful for someone tell me to share it somewhere for download




Theme © iAndrew 2016 - Forum software by © MyBB