xinyb
2024-09-10 8c1986f019fc92360534e4f8b7d1688ac0bff9fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<%@ 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>