【QQ号买卖源码】【java 源码 在线阅读】【实用网站小源码】java md5 源码
1.javaå¦ä½ç®md5ç ï¼
javaå¦ä½ç®md5ç ï¼
å¯ä»¥å©ç¨JDKèªå¸¦çMD5æ¥å å¯ãpublic class MD5Util {public final static String MD5(String s) {
char hexDigits[]={ '0',源码QQ号买卖源码'1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
try {
byte[] btInput = s.getBytes();
// è·å¾MD5æè¦ç®æ³ç MessageDigest 对象
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++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
System.out.println(MD5Util.MD5(""));
System.out.println(MD5Util.MD5("å å¯"));
}
}