手动实现md5加密
public static String md5(String source) {
if(source == null || source.isEmpty()) {
throw new RuntimeException("不能传入空字符串");
}
String algorithm = "md5";
try {
MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
byte[] input = source.getBytes();
byte[] output = messageDigest.digest(input);
int signum = 1;
BigInteger bigInteger = new BigInteger(signum, output);
int radix = 16;
String encoded = bigInteger.toString(radix).toUpperCase();
return encoded;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return null;
}