Created
October 11, 2014 02:38
-
-
Save john990/173c17a374ff198be6d6 to your computer and use it in GitHub Desktop.
获取字符串16进制MD5值(32位)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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