- package com.common.tools;
-
- import java.security.MessageDigest;
-
- public abstract class MD5Tools
- {
- public final static String MD5(String pwd) {
-
- char md5String[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F' };
- try {
-
- byte[] btInput = pwd.getBytes();
-
-
- MessageDigest mdInst = MessageDigest.getInstance("MD5");
-
-
- mdInst.update(btInput);
-
-
- byte[] md = mdInst.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++] = md5String[byte0 >>> 4 & 0xf];
- str[k++] = md5String[byte0 & 0xf];
- }
-
-
- return new String(str);
-
- } catch (Exception e) {
- return null;
- }
- }
- }
- 转自http://blog.csdn.net/clj198606061111/article/details/39722781
posted @
2018-01-11 11:24
人情世故
阅读(
208)
评论()
编辑
收藏
举报
"不管做什么,只要坚持下去就会看到不一样!在路上,不卑不亢!"