encryption_helper.php能帮助解决哪些复杂加密问题?
- 内容介绍
- 文章标签
- 相关推荐
本文共计282个文字,预计阅读时间需要2分钟。
phpencryption_helper.php 加载加密库初始化加密器,使用AES-256-CTR模式,密钥为'bafc42c3d77e1412c7043ddb57aab8bc7e70a0a3e61bdde1571e35d1a422409c'开启加密检查$data是否为数组或对象
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); } } }
本文共计282个文字,预计阅读时间需要2分钟。
phpencryption_helper.php 加载加密库初始化加密器,使用AES-256-CTR模式,密钥为'bafc42c3d77e1412c7043ddb57aab8bc7e70a0a3e61bdde1571e35d1a422409c'开启加密检查$data是否为数组或对象
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); } } }

