飛翔的起點

          從這里出發(fā)

          導航

          <2008年4月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          統(tǒng)計

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          MD5

          import java.security.*;
          import java.security.spec.*;

          class MD5_Test{

          public final static String MD5(String s){
          char hexDigits[] = {
          '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
          'e', 'f'};
          try {
          byte[] strTemp = s.getBytes();
          MessageDigest mdTemp = MessageDigest.getInstance("MD5");
          mdTemp.update(strTemp);
          byte[] md = mdTemp.digest();
          int j = md.length;
          char str[] = new char[j * 2];
          int k = 0;
          for (int i = 0; i < j; i++) {
          byte byte0 = md[i];
          str[k++] = hexDigits[byte0 >>> 4 & 0xf];
          str[k++] = hexDigits[byte0 & 0xf];
          }
          return new String(str);
          }
          catch (Exception e){
          return null;
          }
          }
          public static void main(String[] args){
          //MD5_Test aa = new MD5_Test();

          System.out.print(MD5_Test.MD5("XX"));
          }

          posted on 2008-04-21 10:10 forgood 閱讀(155) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 南靖县| 金山区| 和平区| 苗栗市| 建德市| 蒲江县| 察哈| 乌拉特中旗| 长岛县| 安康市| 涟水县| 丰城市| 枞阳县| 吉林省| 大新县| 雷山县| 柳江县| 威远县| 上饶县| 东平县| 青岛市| 五台县| 阳曲县| 高尔夫| 行唐县| 通渭县| 华容县| 钟祥市| 台南市| 平安县| 钦州市| 三都| 卫辉市| 疏勒县| 泰来县| 凤台县| 昭平县| 兴文县| 临沧市| 靖西县| 水城县|