Name and README update

This commit is contained in:
Ugljesa Jovanovic committed 2019-07-21 12:36:10 +02:00
1 parent 6d8024cf7f
commit 91616fe0e0
9 files changed
+67 -19

No files matched your search

@@ -27,7 +27,7 @@ interface Hash {
}
@ExperimentalUnsignedTypes
interface UpdateableHash : Hash {
interface UpdatableHash : Hash {
fun update(data : Array<UByte>)
fun update(data : String)
@@ -20,7 +20,7 @@ import com.ionspin.kotlin.bignum.integer.BigInteger
import com.ionspin.kotlin.bignum.integer.toBigInteger
import com.ionspin.kotlin.crypto.*
import com.ionspin.kotlin.crypto.hash.StatelessHash
import com.ionspin.kotlin.crypto.hash.UpdateableHash
import com.ionspin.kotlin.crypto.hash.UpdatableHash
/**
* Created by Ugljesa Jovanovic
@@ -29,7 +29,7 @@ import com.ionspin.kotlin.crypto.hash.UpdateableHash
*/
@ExperimentalUnsignedTypes
class Blake2b(val key: Array<UByte>? = null, val hashLength: Int = 64) : UpdateableHash {
class Blake2b(val key: Array<UByte>? = null, val hashLength: Int = 64) : UpdatableHash {
companion object : StatelessHash {
@@ -18,7 +18,7 @@ package com.ionspin.kotlin.crypto.hash.sha
import com.ionspin.kotlin.crypto.chunked
import com.ionspin.kotlin.crypto.hash.StatelessHash
import com.ionspin.kotlin.crypto.hash.UpdateableHash
import com.ionspin.kotlin.crypto.hash.UpdatableHash
import com.ionspin.kotlin.crypto.rotateRight
@@ -30,7 +30,7 @@ import com.ionspin.kotlin.crypto.rotateRight
@ExperimentalUnsignedTypes
class Sha256 : UpdateableHash {
class Sha256 : UpdatableHash {
override val MAX_HASH_BYTES: Int = 32
@@ -18,7 +18,7 @@ package com.ionspin.kotlin.crypto.hash.sha
import com.ionspin.kotlin.crypto.chunked
import com.ionspin.kotlin.crypto.hash.StatelessHash
import com.ionspin.kotlin.crypto.hash.UpdateableHash
import com.ionspin.kotlin.crypto.hash.UpdatableHash
import com.ionspin.kotlin.crypto.rotateRight
/**
@@ -28,7 +28,7 @@ import com.ionspin.kotlin.crypto.rotateRight
*/
@ExperimentalUnsignedTypes
class Sha512 : UpdateableHash {
class Sha512 : UpdatableHash {
override val MAX_HASH_BYTES: Int = 32
@@ -96,5 +96,32 @@ class ReadmeTest {
}
}
@ExperimentalStdlibApi
@Test
fun sha256UpdatableExample() {
val sha256 = Sha256()
sha256.update("abc")
val result = sha256.digest()
val expectedResult = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
assertTrue {
result.contentEquals(expectedResult.chunked(2).map { it.toUByte(16) }.toTypedArray())
}
}
@ExperimentalStdlibApi
@Test
fun sha512UpdatableExample() {
val sha512 = Sha512()
sha512.update("abc")
val result = sha512.digest()
val expectedResult = "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" +
"2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"
assertTrue {
result.contentEquals(expectedResult.chunked(2).map { it.toUByte(16) }.toTypedArray())
}
}
}
@@ -29,7 +29,7 @@ import kotlin.test.assertTrue
class Blake2bInstanceTest {
@Test
fun testUpdateableBlake2b() {
fun testUpdatableBlake2b() {
val updates = 14
val input = "1234567890"
val expectedResult = arrayOf<UByte>(
@@ -26,7 +26,7 @@ import kotlin.test.assertTrue
* on 17-Jul-2019
*/
@ExperimentalUnsignedTypes
class Sha256UpdateableTest {
class Sha256UpdatableTest {
@ExperimentalStdlibApi
@Test
@@ -38,8 +38,6 @@ class Sha256UpdateableTest {
assertTrue {
result.contentEquals(expectedResult.chunked(2).map { it.toUByte(16) }.toTypedArray())
}
}
@ExperimentalStdlibApi
@@ -99,5 +97,4 @@ class Sha256UpdateableTest {
resultDoubleBlock.contentEquals(expectedResultForDoubleBlock.chunked(2).map { it.toUByte(16) }.toTypedArray())
}
}
//50e72a0e 26442fe2 552dc393 8ac58658 228c0cbf b1d2ca87 2ae43526 6fcd055e
}
@@ -25,7 +25,7 @@ import kotlin.test.assertTrue
* ugljesa.jovanovic@ionspin.com
* on 21-Jul-2019
*/
class Sha512UpdateableTest {
class Sha512UpdatableTest {
@ExperimentalStdlibApi
@Test
fun testWellKnownValue() {