PHP:encode和decode

以下转自bo-blog,可以时间传递参数简单加密:

<?php
//以下复制可直接使用,无需修改!
/*以下是id传递参数加密和解密函数*/
function encode($string = '', $skey = 'lvjin') {  
$strArr = str_split(base64_encode($string));
$strCount = count($strArr);
foreach (str_split($skey) as $key => $value)
$key < $strCount && $strArr[$key].=$value;
return str_replace(array('=', '+', '/'), array('O0O0O', 'o000o', 'oo00o'), join('', $strArr));
}

function decode($string = '', $skey = 'lvjin') {
$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));
} 
?>

使用示例:
1、encode前端:

<!-- 前端参数: --> 
<a href="b.php?id=<?php echo encode($row['blogid'],'lvjin');?>" target="_self">加密传递</a>

2、decode还原:

<?php
$id = decode(trim($_GET['id']),'lvjin');
?>