Created
March 10, 2020 18:45
-
-
Save foxicode/f2a805cfcab11a1c89cbec8c00fd76b2 to your computer and use it in GitHub Desktop.
Kotlin String sha1 extension
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
import java.security.MessageDigest | |
val String.sha1: String | |
get() { | |
val bytes = MessageDigest.getInstance("SHA-1").digest(this.toByteArray()) | |
return bytes.joinToString("") { | |
"%02x".format(it) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment