写了一个MD5加密的小方法,
//MD5加密
public static String getMD5(String val) throws NoSuchAlgorithmException {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(val.getBytes());
byte[] m = md5.digest();
return getString(m);
}
private static String getString(byte[] b) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < b.length; i++) {
sb.append(b[i]);
}
return sb.toString();
}