All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.com.algolia.search.helper.internal.Hashing.kt Maven / Gradle / Ivy

package com.algolia.search.helper.internal

import io.ktor.utils.io.core.toByteArray
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec

internal actual fun String.sha256(key: String): String {
    return Mac.getInstance("HmacSHA256").run {
        val secretKey = SecretKeySpec([email protected](), "HmacSHA256")

        init(secretKey)
        val hash = doFinal(key.toByteArray())
        hash.toHex(true)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy