下面是可以将我们的url地址加密.确保我们提交的数据安全,以下是代码片段:
<?php
function keyED($txt,$encrypt_key) '定义一个keyED
{
$encrypt_key = md5($encrypt_key);
$ctr=0;
$tmp = "";
for($i=0;$i&lt;strlen($txt);$i++)
{
if ($ctr==strlen($encrypt_key))
$ctr=0;
$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
$ctr++;
}
return $tmp;
}
function encrypt($txt,$key)
{
$encrypt_key = md5(mt_rand(0,100));
$ctr=0;
$tmp = "";
for ($i=0;$i&lt;strlen($txt);$i++)
{
if ($ctr==strlen($encrypt_key))
$ctr=0;
$tmp.=substr($encrypt_key,$ctr,1) . (substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
$ctr++;
}
return keyED($tmp,$key);
}
function decrypt($txt,$key)
{
$txt = keyED($txt,$key);
$tmp = "";
for($i=0;$i&lt;strlen($txt);$i++)
{
$md5 = substr($txt,$i,1);
$i++;
$tmp.= (substr($txt,$i,1) ^ $md5);
}
return $tmp;
}
function encrypt_url($url,$key)
{
return rawurlencode(base64_encode(encrypt($url,$key)));
}
function decrypt_url($url,$key)
{
return decrypt(base64_decode(rawurldecode($url)),$key);
}
function geturl($str,$key)
{
$str = decrypt_url($str,$key);
$url_array = explode('&amp;',$str);
if (is_array($url_array))
{
foreach ($url_array as $var)
{
$var_array = explode("=",$var);
$vars[$var_array[0]]=$var_array[1];
}
}
return $vars;
}
?>

下面是函数调用的实例,以下是代码片段:

<?php
$key = 'key';
<p>//生产加密参数地址
for ($i=0;$i&lt;10;$i++)
{
echo "&lt;a href=./deurl.php?url=".encrypt_url("id=$i&amp;sdf=asdf&amp;time=".time(),$key)."&gt;php技术文章$i&lt;/a&gt;&lt;br&gt;"; _fcksavedurl=./deurl.php?url=".encrypt_url("id=$i&amp;sdf=asdf&amp;time=".time(),$key)."&gt;php技术文章$i&lt;/a&gt;&lt;br&gt;";
}</p>
<p>//获取参数地址
$get = geturl($_GET['url'],$key);
var_dump($get);</p>
?>

OK就可以就加密了.....