Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter AES解码显示奇怪的字符_Codeigniter_Aes_Decode_Encode - Fatal编程技术网

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
在您的开发机器上捕获这些