MD5工具类
package com.test.common.util;
import org.apache.commons.codec.binary.Hex;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Tools {
private static MessageDigest getMd5() {
try {
return MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ne) {
throw new RuntimeException(ne);
}
}
public static String encript(byte[] byteArr) {
MessageDigest md5 = getMd5();
md5.update(byteArr);
return Hex.encodeHexString(md5.digest());
}
public static String encryptUpperCase(String str) {
return encript(str.getBytes()).toUpperCase();
}
}