Playing around with the API, added optins, will remove annotations in next commit

This commit is contained in:
Ugljesa Jovanovic authored and Ugljesa Jovanovic committed 2020-06-05 20:09:38 +02:00
1 parent 9a1073e1c1
commit d901a45b87
11 files changed
+60 -16

No files matched your search

@@ -539,6 +539,8 @@ kotlin {
all {
languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
}
}
@@ -1,5 +1,7 @@
package com.ionspin.kotlin.crypto
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2b
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2bDelegated
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2bStateless
import com.ionspin.kotlin.crypto.hash.sha.Sha256Pure
import com.ionspin.kotlin.crypto.hash.sha.Sha512Pure
@@ -11,13 +13,34 @@ import com.ionspin.kotlin.crypto.hash.sha.Sha512Pure
*/
@ExperimentalUnsignedTypes
typealias Sha256Stateless = Sha256Pure.Companion
@ExperimentalUnsignedTypes
typealias Sha512Stateless = Sha512Pure.Companion
@ExperimentalUnsignedTypes
object Crypto : CryptoProvider {
override suspend fun initialize() {
Initializer.initialize()
}
@ExperimentalUnsignedTypes
@ExperimentalStdlibApi
object Blake2b {
fun updateable() : com.ionspin.kotlin.crypto.hash.blake2b.Blake2b {
return Blake2bDelegated()
}
fun stateless(message : String) : UByteArray {
println("?")
return Blake2bStateless.digest(message)
}
}
}
@ExperimentalUnsignedTypes
object SimpleCrypto {
fun hash(message : String) : UByteArray { return ubyteArrayOf(0U) }
}
@@ -30,6 +30,7 @@ import com.ionspin.kotlin.crypto.util.rotateRight
@ExperimentalUnsignedTypes
expect class Blake2bDelegated(key: UByteArray? = null, hashLength: Int = 64) : Blake2b
@ExperimentalUnsignedTypes
expect object Blake2bStateless : Blake2bStatelessInterface
@@ -21,9 +21,6 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
}
override fun digest(): UByteArray {
val result = sodium_init()
println("Sodium init")
println(result)
val inputString = "test"
val hashLength = 64
val key : String? = null