php实现URL加密解密

墨辰丷
发布: 2023-03-28 14:46:02
原创
2556 人浏览过

这篇文章主要介绍了php实现URL加密解密的方法,结合实例形式分析了php针对URL字符串进行加密解密操作的相关技巧,需要的朋友可以参考下

具体如下:

<html xmlns="#" lang="zh-CN">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta http-equiv="content-language" content="zh-CN" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="MSThemeCompatible" content="Yes" />
<meta http-equiv="imagetoolbar" content="no" />
<meta http-equiv="widow-target" content="_top" />
<meta name="robots" content="index, follow" />
<meta name="author" content="3945, [email]ljm77@km169.net[/email]" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="copyright" content="Copyright 3945 All Rights Reserved" />
<title>无标题文档</title>
<style type="text/css">
<!--
a, a:link{text-decoration: none; color:#000000; font-size:9pt;}   a:visited{text-decoration: none; color:#000000;}   a:hover{text-decoration: underline; color:red;}
body, td, p, li, p, select{font-size:9pt; font-family:"宋体";}
-->
</style>
</head>
<body>
<?php
function query_encode($sQuery)
{//加密链接
  if(strlen($sQuery)==0)
   {
     return &#39;&#39;;
   }
   else
   {
    $s_tem = preg_replace("/&/i", &#39;&&#39;, $sQuery);
    $s_tem = preg_replace("/&/i", &#39;&&#39;, $s_tem);
    $a_tem = explode(&#39;&&#39;, $s_tem);
    shuffle($a_tem);
    $s_tem = implode(&#39;&&#39;, $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 &#39;&#39;;
   }
   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[&#39;QUERY_STRING&#39;];
   if(strlen($s_query)==0)
   {
     return;
   }
   else
   {
    $s_tem = query_decode($s_query);
    $a_tem = explode(&#39;&&#39;, $s_tem);
     foreach($a_tem as $val)
     {
      $tem = explode(&#39;=&#39;, $val);
      $_GET[$tem[0]] = $tem[1];
     }
   }
}
rebuild_GET();
echo &#39;GET:<pre class="brush:php;toolbar:false">&#39;.print_r($_GET, true).&#39;
'; function testGET() { echo 'Function GET:
&#39;.print_r($_GET, true).&#39;
'; } testGET(); ?>


.$i); echo sprintf('TEST: %s
', $s_url, $s_url); } ?>
登录后复制

以上就是本文的全部内容,希望对大家的学习有所帮助。


相关推荐:

PHP排序算法系列之归并排序详解

thinkPHP5框架数据库连贯操作:cache()用法详情

PHP接口多继承和tarits实现多继承效果的方法教程详情

以上是php实现URL加密解密的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!