当前位置: 移动技术网 > IT编程>开发语言>PHP > php实现URL加密解密的方法

php实现URL加密解密的方法

2017年12月12日  | 移动技术网IT编程  | 我要评论

六道狂神,西北公众网,媒体平台

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

<html xmlns="http://www.w3.org/1999/xhtml" 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, div, select{font-size:9pt; font-family:"宋体";}
-->
</style>
</head>
<body>
<?php
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:<pre>'.print_r($_get, true).'</pre>';
function testget()
{
   echo 'function get:<pre>'.print_r($_get, true).'</pre>';
}
testget();
?>
<br /><br /><br />
<?
for($i=1; $i<10; $i++)
{
  $s_url = query_encode('ac=index:logo& style="color: #007700">.$i);
   echo sprintf('<a href="?%s">test: %s</a><br />', $s_url, $s_url);
}
?>
</body>
</html>

ps:关于加密解密感兴趣的朋友还可以参考本站在线工具:

url网址16进制加密工具:

密码安全性在线检测:

高强度密码生成器:

md5在线加密工具:

迅雷、快车、旋风url加密/解密工具:

在线散列/哈希算法加密工具:

更多关于php相关内容感兴趣的读者可查看本站专题:《php加密方法总结》、《php编码与转码操作技巧汇总》、《php面向对象程序设计入门教程》、《php数学运算技巧总结》、《php数组(array)操作技巧大全》、《php字符串(string)用法总结》、《php数据结构与算法教程》、《php程序设计算法总结》、《php正则表达式用法总结》、及《php常见数据库操作技巧汇总

希望本文所述对大家php程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网