Playing around with the API, added optins, will remove annotations in next commit
This commit is contained in:
parent
9a1073e1c1
commit
d901a45b87
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -16,6 +16,6 @@
|
||||
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -259,6 +259,8 @@ kotlin {
|
||||
|
||||
all {
|
||||
languageSettings.enableLanguageFeature("InlineClasses")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,9 @@ import com.ionspin.kotlin.crypto.hash.UpdatableHash
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 24-May-2020
|
||||
*/
|
||||
@ExperimentalUnsignedTypes
|
||||
interface Blake2b : UpdatableHash
|
||||
@ExperimentalUnsignedTypes
|
||||
interface Blake2bStatelessInterface : StatelessHash {
|
||||
@ExperimentalUnsignedTypes
|
||||
override val MAX_HASH_BYTES: Int
|
||||
|
@ -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
|
||||
|
@ -344,6 +344,8 @@ kotlin {
|
||||
|
||||
all {
|
||||
languageSettings.enableLanguageFeature("InlineClasses")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,6 +269,8 @@ kotlin {
|
||||
|
||||
all {
|
||||
languageSettings.enableLanguageFeature("InlineClasses")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,17 @@
|
||||
package com.ionspin.kotlin.crypto.sample
|
||||
|
||||
object Sample {
|
||||
fun blakehash() {
|
||||
import com.ionspin.kotlin.crypto.Crypto
|
||||
import com.ionspin.kotlin.crypto.CryptoProvider
|
||||
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2b
|
||||
import com.ionspin.kotlin.crypto.util.toHexString
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
object Sample {
|
||||
suspend fun runSample() {
|
||||
Crypto.initialize()
|
||||
val blake2bUpdateable = Crypto.Blake2b.updateable()
|
||||
blake2bUpdateable.update("test")
|
||||
println(blake2bUpdateable.digest().toHexString())
|
||||
}
|
||||
}
|
@ -1,18 +1,21 @@
|
||||
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2bDelegated
|
||||
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2bStateless
|
||||
import com.ionspin.kotlin.crypto.sample.Sample
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.measureTime
|
||||
|
||||
@ExperimentalTime
|
||||
@ExperimentalStdlibApi
|
||||
fun main() {
|
||||
println("Test")
|
||||
// Blake
|
||||
val blake = Blake2bDelegated()
|
||||
val res = blake.digest()
|
||||
println("Result of res")
|
||||
// println(res)
|
||||
val staticRes = Blake2bStateless.digest("test")
|
||||
println("Result:")
|
||||
println(staticRes)
|
||||
fun main() = runBlocking {
|
||||
Sample.runSample()
|
||||
// println("Test")
|
||||
//// Blake
|
||||
// val blake = Blake2bDelegated()
|
||||
// val res = blake.digest()
|
||||
// println("Result of res")
|
||||
//// println(res)
|
||||
// val staticRes = Blake2bStateless.digest("test")
|
||||
// println("Result:")
|
||||
// println(staticRes)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user