<2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          統計

          • 隨筆 - 0
          • 文章 - 22
          • 評論 - 11
          • 引用 - 0

          留言簿

          文章分類(22)

          文章檔案(21)

          牛B天地

          搜索

          •  

          最新評論

          JAVA:MD5不可逆加密算法
           1 import java.security.MessageDigest;
           2 import java.security.*;
           3 import java.security.spec.*;
           4 
           5 /*
           6  * To change this template, choose Tools | Templates
           7  * and open the template in the editor.
           8  */
           9 /**
          10  *
          11  * @author Administrator
          12  */
          13 public class MD5 {
          14     public final static String MD5(String s) {
          15         char hexDigits[] = {
          16             '0''1''2''3''4''5''6''7''8''9''a''b''c''d',
          17             'e''f'
          18         };
          19         try {
          20             byte[] strTemp = s.getBytes();
          21             MessageDigest mdTemp = MessageDigest.getInstance("MD5");
          22             mdTemp.update(strTemp);
          23             byte[] md = mdTemp.digest();
          24             int j = md.length;
          25             char str[] = new char[j * 2];
          26             int k = 0;
          27             for (int i = 0; i < j; i++) {
          28                 byte byte0 = md[i];
          29                 str[k++= hexDigits[byte0 >>> 4 & 0xf];
          30                 str[k++= hexDigits[byte0 & 0xf];
          31             }
          32             return new String(str);
          33         } catch (Exception e) {
          34             return null;
          35         }
          36     }
          37 }
          38 

          posted on 2009-05-23 10:27 YeeYang 閱讀(728) 評論(0)  編輯  收藏 所屬分類: 程序設計

          主站蜘蛛池模板: 自贡市| 内江市| 长顺县| 界首市| 含山县| 濮阳县| 津市市| 南宁市| 抚顺县| 阳曲县| 青川县| 西贡区| 崇州市| 磐石市| 额尔古纳市| 盖州市| 石楼县| 平泉县| 屏东市| 蓬溪县| 泰和县| 宜州市| 聊城市| 朔州市| 楚雄市| 阜平县| 米林县| 三明市| 财经| 恩平市| 鄂尔多斯市| 嵊泗县| 黄龙县| 社旗县| 扎囊县| 抚远县| 临澧县| 六盘水市| 富川| 齐齐哈尔市| 绵竹市|