文章来源:
[url]http://blog.csdn.net/missyesterday/archive/2005/01/18/257565.aspx[/url]
public static String encrypt_md5(String srcStr)
{
String hexStr="0123456789abcdef";
String result="";
try
{
java.security.MessageDigest md5=java.security.MessageDigest.getInstance("MD5");
md5.update(srcStr.getBytes());
byte bytes[]=md5.digest();
for(int i=0;i<bytes.length;i++)
{
int temp=bytes <0?bytes+256:bytes;
result=result+hexStr.charAt((temp/16)%16)+hexStr.charAt(temp%16);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
return result;
public static String encrypt_md5(String srcStr)
{
String hexStr="0123456789abcdef";
String result="";
try
{
java.security.MessageDigest md5=java.security.MessageDigest.getInstance("MD5");
md5.update(srcStr.getBytes());
byte bytes[]=md5.digest();
for(int i=0;i<bytes.length;i++)
{
int temp=bytes <0?bytes+256:bytes;
result=result+hexStr.charAt((temp/16)%16)+hexStr.charAt(temp%16);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
return result;
}
本文转自loveme2351CTO博客,原文链接: http://blog.51cto.com/loveme23/7949,如需转载请自行联系原作者