Created
July 7, 2017 09:34
-
-
Save dlimpid/68761108b49b7c1ddb84250dfac78495 to your computer and use it in GitHub Desktop.
Get MD5 hash of the string (of length 32, with leading zeros) in Kotlin
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
import java.math.BigInteger | |
import java.security.MessageDigest | |
fun String.md5(): String { | |
val md = MessageDigest.getInstance("MD5") | |
return BigInteger(1, md.digest(toByteArray())).toString(16).padStart(32, '0') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment