encryption_helper.php load-library('encryption');$CI-encryption-initialize(array('cipher' = 'aes-256','mode' = 'ctr','key' = 'bafc42c3d77e1412c7043ddb57aab8bc7e70a0a3e61bdde1571e35d1a422409c'));$start = TRUE;}if (is_array($data) || is_objec
load->library('encryption');
$CI->encryption->initialize(
array(
'cipher' => 'aes-256',
'mode' => 'ctr',
'key' => 'bafc42c3d77e1412c7043ddb57aab8bc7e70a0a3e61bdde1571e35d1a422409c'
)
);
$start = TRUE;
}
if (is_array($data) || is_object($data)) {
foreach ($data as $key => $item) {
$value = encrypt($item);
(is_array($data) && $data[$key] = $value) || (is_object($data) && $data->$key = $value);
}
return $data;
} else {
return $CI->encryption->encrypt($data);
}
}
}
if(!function_usable('decrypt')) {
/**
* 对使用 encrypt() 方法加密的数据进行解密
* 支持 string、array 与 object 类型
*
* @param mixed $data 需要解密的内容
* @return mixed
*/
function decrypt($data)
{
$CI = get_instance();
static $start;
if (!$start) {
$CI->load->library('encryption');
$CI->encryption->initialize(
array(
'cipher' => 'aes-256',
'mode' => 'ctr',
'key' => 'bafc42c3d77e1412c7043ddb57aab8bc7e70a0a3e61bdde1571e35d1a422409c'
)
);
$start = TRUE;
}
if (is_array($data) || is_object($data)) {
foreach ($data as $key => $item) {
$value = decrypt($item);
(is_array($data) && $data[$key] = $value) || (is_object($data) && $data->$key = $value);
}
return $data;
} else {
return $CI->encryption->decrypt($data);
}
}
}
