A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© halohoop 中级黑马   /  2015-7-23 21:30  /  266 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. import java.security.MessageDigest;
  2. ...
  3. ...
  4.         public static String md5It(String str) throws NoSuchAlgorithmException{
  5.                 StringBuffer sb = new StringBuffer();
  6.                 // 信息摘要器MessageDigest
  7.                 MessageDigest digest = MessageDigest.getInstance("md5");
  8.                 byte[] bs = digest.digest(str.getBytes());
  9.                 for(byte b : bs){
  10.                         int i = b & 0xff;
  11.                         String hexString = Integer.toHexString(i);
  12.                         if(hexString.length()==1){
  13.                                 sb.append("0");
  14.                         }
  15.                         sb.append(hexString);
  16.                         System.out.println(sb);
  17.                 }
  18.                 return sb.toString();
  19.         }
  20. ...
  21. ...
复制代码

欢迎勘误。:):)

3 个回复

正序浏览
已经学到这么高深的地方了
回复 使用道具 举报
赞一个  顶起来
回复 使用道具 举报
虽然,我不知道写的是什么。但是看起来好像很厉害的样子。赞一个~~~
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马