<%@ page contentType="text/html;charset=utf-8"%>
|
<%
|
//@author hq
|
//2010-6-24
|
%>
|
<%@page import="com.yc.utils.EncodeUtil"%>
|
<%
|
//得到URL
|
String URL = (request.getRequestURL() + "").replace(request
|
.getRequestURI(), "")
|
+ request.getContextPath();
|
%>
|
<!DOCTYPE HTML >
|
<html>
|
<head>
|
<base href="<%=URL%>">
|
|
<title>加密解密测试</title>
|
|
<meta http-equiv="pragma" content="no-cache">
|
<meta http-equiv="cache-control" content="no-cache">
|
<meta http-equiv="expires" content="0">
|
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
|
<meta http-equiv="description" content="This is my page">
|
<script type="text/javascript" src="<%=URL%>/js/encode.js"></script>
|
<script type="text/javascript">
|
function test(){
|
var temp=document.getElementById("str").value;
|
var value=ENCODE.encode(temp);
|
document.getElementById("e_str").value=value;
|
document.getElementById("link").innerHTML="<a href='<%=URL%>/decode.jsp?"+value+"'><%=URL%>/decode.jsp?"+value+"</a>"
|
}
|
|
</script>
|
|
</head>
|
<body>
|
<%
|
if(request.getParameter("str2")!=null){
|
String queryString=request.getParameter("str2");
|
queryString=queryString.replaceAll("%2B","+");
|
queryString=queryString.replaceAll("%2F","/");
|
System.out.println(queryString);
|
String t="";
|
if(queryString.indexOf("?")!=-1){
|
t=queryString.substring(0,queryString.indexOf("?")+1);
|
queryString=queryString.substring(queryString.indexOf("?"));
|
}
|
try{
|
queryString=EncodeUtil.base64Decode(queryString);
|
}catch(Exception e){
|
|
}
|
|
out.write("解密后的地址:"+t+queryString);
|
}
|
%>
|
|
<br>
|
<br/>
|
<input type="text" id="str" ><input type="button" onclick="test();" value="加密"/>
|
<input type="text" id="e_str"><br>
|
<div id="link"></div>
|
<form action="/decode.jsp" method="post">
|
<br />您需要解密的地址:<input type="text" name="str2" style="width:300px;" ><input type="submit" value="解密"/>
|
</form>
|
|
<div>
|
http://localhost:8080/decode.jsp?世界你好
|
<br/>
|
http://localhost:8080/decode.jsp?5LiW55WM5L2g5aW9
|
</div>
|
</body>
|
</html>
|