INNER CODE UNIT · Kotlin
genericHashStep1b
terl/lazysodium-java · sample-app/src/main/kotlin/Main.kt:220
private fun genericHashStep1b() {
val randomKey: ByteArray = lazySodium.randomBytesBuf(GenericHash.KEYBYTES)
printStep(
"1b",
"Deterministic key hash using Native",
"The following hashes should be the same as we're using " +
"identical keys for them.",
"We will be using the random key '" + lazySodium.toHexStr(randomKey) + "'."
)
val nativeGH: com.goterl.lazysodium.interfaces.GenericHash.Native =
lazySodium as com.goterl.lazysodium.interfaces.GenericHash.Native
val message: ByteArray = lazySodium.bytes("Top secret message.")
val hash: ByteArray = lazySodium.randomBytesBuf(GenericHash.BYTES)
val hash2: ByteArray = lazySodium.randomBytesBuf(GenericHash.BYTES)
val res: Boolean =
nativeGH.cryptoGenericHash(hash, hash.size, message, message.size.toLong(), randomKey, randomKey.size)
val res2: Boolean =
nativeGH.cryptoGenericHash(hash2, hash2.size, message, message.size.toLong(), randomKey, randomKey.size)