32位加密
public static String getMD5(String strSrc) {
StringBuffer buf = null;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(strSrc.getBytes());
byte b[] = md.digest();
int i;
buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if(i<0) i+= 256;
if(i<16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
// Log.e("555","result: " + buf.toString());//32位的加密
//Log.e("555","result: " + buf.toString().substring(8,24));//16位的加密
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return buf.toString();
}原文:http://blog.csdn.net/u010152805/article/details/41984369