注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 [业内传闻]今天,7月25日..
 帮助

md5加密算法


2005-04-19 18:26:00
 标签:加密   [推送到技术圈]

文章来源:http://blog.csdn.net/missyesterday/archive/2005/01/18/257565.aspx

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;

}





    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: