具体代码如下:
$value)
$key < $strCount && $strArr[$key].=$value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
}
/**
* 简单对称加密算法之解密
* @param String $string 需要解密的字串
* @param String $skey 解密KEY
*/
function decode($string = '', $skey = 'yourkey') {
$strArr = str_split(str_replace(array('O0O0O', 'o000o', 'oo00o'), array('=', '+', '/'), $string), 2);
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key <= $strCount && $strArr[$key][1] === $value && $strArr[$key] = $strArr[$key][0];
return base64_decode(join('', $strArr));
}
/**
将以上两个函数放在Common下的function.php公共函数中。
用法:常用语get传参
前端:encode($data['id']),'name'=>encode($data['title'])))}>" rel="external nofollow" ><{$data.title}>
后台:view方法中:$id = decode(trim(I("get.id")));即可还原
view模板中:<{$Think.get.name|decode}>
**/
/*建议将key自行修改,尽量不要太长,不然url很长,适当即可,加密性能很好,亲测*/