xinyb
2024-04-23 2ef61846432762b570d5f2004a4551225da01324
提交 | 用户 | age
a6a76f 1 <%@ page contentType="text/html;charset=utf-8"%>
F 2 <%
3     //@author hq
4     //2010-6-24
5 %>
6 <%@page import="com.yc.utils.EncodeUtil"%>
7 <%
8     //得到URL
9     String URL = (request.getRequestURL() + "").replace(request
10             .getRequestURI(), "")
11             + request.getContextPath();
12 %>
4a551f 13 <!DOCTYPE HTML >
a6a76f 14 <html>
F 15 <head>
16 <base href="<%=URL%>">
17
18 <title>加密解密测试</title>
19
20 <meta http-equiv="pragma" content="no-cache">
21 <meta http-equiv="cache-control" content="no-cache">
22 <meta http-equiv="expires" content="0">
23 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
24 <meta http-equiv="description" content="This is my page">
25 <script type="text/javascript" src="<%=URL%>/js/encode.js"></script>
26 <script type="text/javascript">
27 function test(){
28     var temp=document.getElementById("str").value;
29     var value=ENCODE.encode(temp);
30     document.getElementById("e_str").value=value;
31     document.getElementById("link").innerHTML="<a href='<%=URL%>/decode.jsp?"+value+"'><%=URL%>/decode.jsp?"+value+"</a>"
32 }
33
34 </script>
35
36 </head>
37 <body>
38 <% 
39     if(request.getParameter("str2")!=null){
40         String queryString=request.getParameter("str2");
41         queryString=queryString.replaceAll("%2B","+");
42         queryString=queryString.replaceAll("%2F","/");
43         System.out.println(queryString);
44         String t="";
45         if(queryString.indexOf("?")!=-1){
46             t=queryString.substring(0,queryString.indexOf("?")+1);
47             queryString=queryString.substring(queryString.indexOf("?"));
48         }
49         try{
50         queryString=EncodeUtil.base64Decode(queryString);
51         }catch(Exception e){
52             
53         }
54     
55         out.write("解密后的地址:"+t+queryString);
56     }
57 %>
58
59 <br>
60 <br/>
61 <input type="text" id="str" ><input type="button" onclick="test();" value="加密"/>
62   <input  type="text" id="e_str"><br>
63 <div id="link"></div>
64 <form action="/decode.jsp" method="post">
65 <br />您需要解密的地址:<input type="text" name="str2" style="width:300px;" ><input type="submit"  value="解密"/>
66 </form>
67
68 <div>
69 http://localhost:8080/decode.jsp?世界你好
70 <br/>
71 http://localhost:8080/decode.jsp?5LiW55WM5L2g5aW9
72 </div>
73 </body>
74 </html>