Created
May 23, 2012 17:58
-
-
Save mcenirm/2776691 to your computer and use it in GitHub Desktop.
get MD5 digest for input string
This file contains hidden or 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
/** | |
* get MD5 digest for input string | |
* TODO: pad with leading zeros | |
*/ | |
String md5(String data) { | |
return ( | |
new java.math.BigInteger( | |
1, | |
java.security.MessageDigest.getInstance( | |
"MD5" | |
).digest( | |
data.getBytes() | |
) | |
) | |
).toString(16); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment