Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > php技巧

php实现URL加密解密的方法

来源:中文源码网    浏览:267 次    日期:2024-04-29 15:31:32
【下载文档:  php实现URL加密解密的方法.txt 】


php实现URL加密解密的方法
本文实例讲述了php实现URL加密解密的方法。分享给大家供大家参考,具体如下:














无标题文档



function query_encode($sQuery)
{//加密链接
if(strlen($sQuery)==0)
{
return '';
}
else
{
$s_tem = preg_replace("/&/i", '&', $sQuery);
$s_tem = preg_replace("/&/i", '&', $s_tem);
$a_tem = explode('&', $s_tem);
shuffle($a_tem);
$s_tem = implode('&', $a_tem);
$s_tem = rawurlencode($s_tem);
$s_tem = base64_encode($s_tem);
$s_tem = strrev($s_tem);
return $s_tem;
}
}
function query_decode($sEncode)
{//解密链接
if(strlen($sEncode)==0)
{
return '';
}
else
{
$s_tem = strrev($sEncode);
$s_tem = base64_decode($s_tem);
$s_tem = rawurldecode($s_tem);
return $s_tem;
}
}
function rebuild_GET()
{//重写$_GET全局变量
$_GET = array();
$s_query = $_SERVER['QUERY_STRING'];
if(strlen($s_query)==0)
{
return;
}
else
{
$s_tem = query_decode($s_query);
$a_tem = explode('&', $s_tem);
foreach($a_tem as $val)
{
$tem = explode('=', $val);
$_GET[$tem[0]] = $tem[1];
}
}
}
rebuild_GET();
echo 'GET:
'.print_r($_GET, true).'
';
function testGET()
{
echo 'Function GET:
'.print_r($_GET, true).'
';
}
testGET();
?>




for($i=1; $i<10; $i++)
{
$s_url = query_encode('ac=index:logo& style="color: #007700">.$i);
echo sprintf('TEST: %s
', $s_url, $s_url);
}
?>


PS:关于加密解密感兴趣的朋友还可以参考本站在线工具:
URL网址16进制加密工具:
http://tools.zwyuanma.com/password/urlencodepwd
密码安全性在线检测:
http://tools.zwyuanma.com/password/my_password_safe
高强度密码生成器:
http://tools.zwyuanma.com/password/CreateStrongPassword
MD5在线加密工具:
http://tools.zwyuanma.com/password/CreateMD5Password
迅雷、快车、旋风URL加密/解密工具:
http://tools.zwyuanma.com/password/urlrethunder
在线散列/哈希算法加密工具:
http://tools.zwyuanma.com/password/hash_encrypt
更多关于PHP相关内容感兴趣的读者可查看本站专题:《php加密方法总结》、《PHP编码与转码操作技巧汇总》、《php面向对象程序设计入门教程》、《PHP数学运算技巧总结》、《PHP数组(Array)操作技巧大全》、《php字符串(string)用法总结》、《PHP数据结构与算法教程》、《php程序设计算法总结》、《php正则表达式用法总结》、及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。

相关内容