Reputation: 49817
i tryed:
$data = array('ip'=>'120.0.3.4','user'=>'robert');
$this->load->library('encrypt');
$this->encrypt->set_cipher(MCRYPT_RIJNDAEL_256);
$this->encrypt->set_mode(MCRYPT_MODE_ECB);
$key = random_string();
$o=$this->encrypt->encode($data,$key);
var_dump($o);
$this->encrypt->set_cipher(MCRYPT_RIJNDAEL_256);
$this->encrypt->set_mode(MCRYPT_MODE_ECB);
$o = $this->encrypt->decode($o,$key);
var_dump($o);
it retunrs strange chars in decoding:
string(44) "CVwMzZGkzagW4wHbUZfNpVWACQp2Fx4TeAO2KLqZs3I=" string(32) "��pz��xJx�jʊ8�Kw��mS�Y �1�_�"
any suggestion?
is this caused from the array encryption? i need to encrypt value by value instead of encrypt all the array to use the array of encrypted data?? thx
Upvotes: 0
Views: 1089
Reputation: 7388
You are passing an array into $this->encrypt->encode()
. The encode()
method takes a string. See Encryption Class.
If you had PHP errors enabled you would also see:
A PHP Error was encountered
Severity: Warning
Message: mcrypt_encrypt() expects parameter 3 to be string, array given
Filename: libraries/Encrypt.php
Turn PHP errors on on your development machine to catch these.
Upvotes: 2