Codeigniter AES解码显示奇怪的字符
我试着:Codeigniter AES解码显示奇怪的字符,codeigniter,aes,decode,encode,Codeigniter,Aes,Decode,Encode,我试着: $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=
$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);
它在解码时重现了奇怪的字符:
string(44) "CVwMzZGkzagW4wHbUZfNpVWACQp2Fx4TeAO2KLqZs3I=" string(32) "��pz��xJx�jʊ8�Kw��mS�Y �1�_�"
有什么建议吗
这是由阵列加密引起的吗?我需要逐值加密,而不是加密所有数组,才能使用加密数据数组??
thx您正在将数组传递到
$this->encrypt->encode()
中。encode()
方法接受一个字符串。看
如果启用了PHP错误,您还会看到:
A PHP Error was encountered
Severity: Warning
Message: mcrypt_encrypt() expects parameter 3 to be string, array given
Filename: libraries/Encrypt.php
在您的开发机器上捕获这些