package com.test
import java.security.*;
import java.math.*;
public class TestMd5
{
public String MD5(String sInput) throws Exception{
String algorithm=””;
//输入不能为空
if(sInput.trim()==null){
return “null”;
}
//指定采用MD5算法
try{
algorithm=System.getProperty(“MD5.algorithm”,”MD5″);
}catch(SecurityException se){
}
//定义MessageDigest对象
MessageDigest md=MessageDigest.getInstance(algorithm);
//按照系统缺省的字符编码方式把sInput 转换成字节,并把结果存到一新的字节数组buffer中
byte buffer[]=sInput.getBytes();
//从指定的字节数组buffer的偏移量0开始,用指定的字节数组修改由sInput生成摘要
//count为从 0 开始用的字节数长度。
for(int count=0;count
<%
TestMd5 my = new TestMd5();
try
{
out.println(my.MD5("9999"));
}catch (Exception e){}
%>