initial commit
All checks were successful
/ publish (push) Successful in 3m9s

This commit is contained in:
2025-07-12 20:04:39 +02:00
commit 1300e1d728
14 changed files with 776 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package com.infendro.otp
import com.infendro.hash.*
import kotlin.random.Random
object SecretGenerator {
private val random = Random.Default
fun generate(
algorithm: HashFunction = SHA1,
): ByteArray {
val bytes = when (algorithm) {
MD5 -> 16
SHA1 -> 20
SHA224 -> 28
SHA256 -> 32
SHA384 -> 48
SHA512 -> 64
}
return ByteArray(bytes).also {
random.nextBytes(it)
}
}
}