Kotlin SHA-1

To calculate the SHA-1 hash in Kotlin, you can follow these steps:

  1. Import the necessary classes:
  2. import java.security.MessageDigest
  3. import java.nio.charset.StandardCharsets

  4. Define a function to calculate the SHA-1 hash: kotlin fun sha1(input: String): String { val digest = MessageDigest.getInstance("SHA-1") val bytes = digest.digest(input.toByteArray(StandardCharsets.UTF_8)) return bytes.joinToString("") { "%02x".format(it) } }

  5. Call the sha1 function with your desired input: kotlin val input = "Your input string" val sha1Hash = sha1(input)

Let me know if you have any further questions.