md5 jsp頁面,加密用
String key = request.getParameter("key");
String md5str = request.getParameter("str");
if(md5str==null||md5str.equals("")||key==null||key.equals("")){
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="/">
str:<input name="str"></br>
key:<input name="key"></br>
<input type="submit" value="submit"/>
</form>
<div style="display: none">
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1255376747'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1255376747%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));</script>
</div>
</body>
</html>
<%
}else{
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(md5str.getBytes("UTF-8"));
String result="";
byte[] temp;
temp=md5.digest(key.getBytes("UTF-8"));
for (int i=0; i<temp.length; i++){
result+=Integer.toHexString((0x000000ff & temp[i]) | 0xffffff00).substring(6);
}
out.print(result);
}
%>
<%@page trimDirectiveWhitespaces="true" import="java.security.NoSuchAlgorithmException,java.security.MessageDigest" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>