new167.jsp
<%@page import="java.util.Base64.Encoder"%>
<%@page import="java.security.NoSuchAlgorithmException"%>
<%@page import="java.util.Base64"%>
<%@page import="java.security.MessageDigest"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String oldstr = request.getParameter("oldstr");
byte[] oldBytes = oldstr.getBytes();
MessageDigest md;
try
{
md = MessageDigest.getInstance("MD5");
byte[] newBytes = md.digest(oldBytes);
Encoder encoder = Base64.getEncoder();
String newStr = encoder.encodeToString(newBytes);
out.print("oldstr=" + oldstr);
out.print("<br>");
out.print("newStr=" + newStr);
}
catch(NoSuchAlgorithmException e)
{
e.printStackTrace();
}
finally
{
}
%>
</body>
</html>