INNER CODE UNIT · Kotlin
genericHashStep1
terl/lazysodium-java · sample-app/src/main/kotlin/Main.kt:180
private fun genericHashStep1() {
printSection("Running generic hash")
// We can generate a random key or
// we can provide a key.
// String randomKey = lazySodium.cryptoGenericHashKeygen();
// Key must be larger than GenericHash.KEYBYTES_MIN
// but less than GenericHash.KEYBYTES_MAX
val key = "randomkeyoflength16bytes"
printStep(
"1",
"Deterministic key hash",
"The following hashes should be the same as we're using " +
"identical keys for them.",
"We will be using the key '$key'."
)
val hash: String = lazySodium.cryptoGenericHash("", Key.fromPlainString(key))