implement Blake2b and Blake2s

This commit is contained in:
2025-12-02 19:34:26 +01:00
parent 3ff0ad1b91
commit 85ab748c07
6 changed files with 389 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package com.infendro.hash.blake2
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
class `Blake2s-224 Test` {
val function = Blake2s(28)
@Test
fun `bytes and block`() {
assertEquals(28, function.bytes)
assertEquals(224, function.bits)
assertEquals(64, function.block)
}
@Test
fun `empty bytearray`() {
val expected = ubyteArrayOf(
0x1fU, 0xa1U, 0x29U, 0x1eU,
0x65U, 0x24U, 0x8bU, 0x37U,
0xb3U, 0x43U, 0x34U, 0x75U,
0xb2U, 0xa0U, 0xddU, 0x63U,
0xd5U, 0x4aU, 0x11U, 0xecU,
0xc4U, 0xe3U, 0xe0U, 0x34U,
0xe7U, 0xbcU, 0x1eU, 0xf4U,
)
val actual = function.hash(
UByteArray(0)
)
assertContentEquals(expected, actual)
}
}