Skip to content

Instantly share code, notes, and snippets.

@john990
Created October 11, 2014 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john990/173c17a374ff198be6d6 to your computer and use it in GitHub Desktop.
Save john990/173c17a374ff198be6d6 to your computer and use it in GitHub Desktop.
获取字符串16进制MD5值(32位)
/**
* 16进制MD5值
* @param message
* @return
* @throws Exception
*/
private String hexdigest(String message) throws Exception {
String hd;
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(message.getBytes());
BigInteger hash = new BigInteger(1, md5.digest());
hd = hash.toString(16);
while (hd.length() < 32) {
hd = "0" + hd;
}
return hd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment