Skip to content

Instantly share code, notes, and snippets.

@foxicode
Created March 10, 2020 18:45
Show Gist options
  • Save foxicode/f2a805cfcab11a1c89cbec8c00fd76b2 to your computer and use it in GitHub Desktop.
Save foxicode/f2a805cfcab11a1c89cbec8c00fd76b2 to your computer and use it in GitHub Desktop.
Kotlin String sha1 extension
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