<%@ page contentType="text/html; charset=GBK"%>
<%@page import="java.math.BigInteger"%>
<%@page import="java.security.MessageDigest"%>
<%
MessageDigest md5 = null;
md5 = MessageDigest.getInstance("MD5");
String s = "123"; //这个是需要加密的字符串
String miyao = "abc"; //这个算是密钥
String jiamichuan = s + miyao; //转换后的加密串
md5.update(jiamichuan.getBytes());
String md5String = new BigInteger(1, md5.digest()).toString(16);//加密之后的字符串
out.println(md5String);
%>
来源:http://blog.sina.com.cn/s/blog_602e25630100zzma.html