use UByteArray for SecretGenerator

This commit is contained in:
2025-12-13 02:28:53 +01:00
parent aa686cd81e
commit 62d5438b3b

View File

@@ -2,13 +2,14 @@ package com.infendro.otp
import com.infendro.hash.HashFunction import com.infendro.hash.HashFunction
import com.infendro.random.csprng.CSPRNG import com.infendro.random.csprng.CSPRNG
import kotlin.random.nextUBytes
class SecretGenerator( class SecretGenerator(
val function: HashFunction, val function: HashFunction,
) { ) {
private val random = CSPRNG.HMAC(function) private val random = CSPRNG.HMAC(function)
fun generate(): ByteArray { fun generate(): UByteArray {
return random.nextBytes(function.bytes) return random.nextUBytes(function.bytes)
} }
} }