首页 > 其他 > 详细

md5加密

时间:2016-12-28 20:54:43      阅读:241      评论:0      收藏:0      [点我收藏+]

public static String md5(String inStr) throws Exception {

        MessageDigest md5 = null;        

try {            

      md5 = MessageDigest.getInstance("MD5");        

} catch (Exception e) {            

   System.out.println(e.toString());            

  e.printStackTrace();            

   return "";        

}

       byte[] byteArray = inStr.getBytes("UTF-8");        

   byte[] md5Bytes = md5.digest(byteArray);        

      StringBuffer hexValue = new StringBuffer();        

      for (int i = 0; i < md5Bytes.length; i++) {            

    int val = ((int) md5Bytes[i]) & 0xff;            

      if (val < 16) {                

        hexValue.append("0");            

       }            

   hexValue.append(Integer.toHexString(val));        

   }        

  return hexValue.toString();    

}

md5加密

原文:http://www.cnblogs.com/cuijinlong/p/6230226.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!