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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -259,6 +259,8 @@ kotlin {
|
|||||||
|
|
||||||
all {
|
all {
|
||||||
languageSettings.enableLanguageFeature("InlineClasses")
|
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
|
* ugljesa.jovanovic@ionspin.com
|
||||||
* on 24-May-2020
|
* on 24-May-2020
|
||||||
*/
|
*/
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
interface Blake2b : UpdatableHash
|
interface Blake2b : UpdatableHash
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
interface Blake2bStatelessInterface : StatelessHash {
|
interface Blake2bStatelessInterface : StatelessHash {
|
||||||
@ExperimentalUnsignedTypes
|
@ExperimentalUnsignedTypes
|
||||||
override val MAX_HASH_BYTES: Int
|
override val MAX_HASH_BYTES: Int
|
||||||
|
@ -539,6 +539,8 @@ kotlin {
|
|||||||
|
|
||||||
all {
|
all {
|
||||||
languageSettings.enableLanguageFeature("InlineClasses")
|
languageSettings.enableLanguageFeature("InlineClasses")
|
||||||
|
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||||
|
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.ionspin.kotlin.crypto
|
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.blake2b.Blake2bStateless
|
||||||
import com.ionspin.kotlin.crypto.hash.sha.Sha256Pure
|
import com.ionspin.kotlin.crypto.hash.sha.Sha256Pure
|
||||||
import com.ionspin.kotlin.crypto.hash.sha.Sha512Pure
|
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
|
typealias Sha256Stateless = Sha256Pure.Companion
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
typealias Sha512Stateless = Sha512Pure.Companion
|
typealias Sha512Stateless = Sha512Pure.Companion
|
||||||
|
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
object Crypto : CryptoProvider {
|
object Crypto : CryptoProvider {
|
||||||
override suspend fun initialize() {
|
override suspend fun initialize() {
|
||||||
Initializer.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
|
@ExperimentalUnsignedTypes
|
||||||
expect class Blake2bDelegated(key: UByteArray? = null, hashLength: Int = 64) : Blake2b
|
expect class Blake2bDelegated(key: UByteArray? = null, hashLength: Int = 64) : Blake2b
|
||||||
|
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
expect object Blake2bStateless : Blake2bStatelessInterface
|
expect object Blake2bStateless : Blake2bStatelessInterface
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,9 +21,6 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun digest(): UByteArray {
|
override fun digest(): UByteArray {
|
||||||
val result = sodium_init()
|
|
||||||
println("Sodium init")
|
|
||||||
println(result)
|
|
||||||
val inputString = "test"
|
val inputString = "test"
|
||||||
val hashLength = 64
|
val hashLength = 64
|
||||||
val key : String? = null
|
val key : String? = null
|
||||||
|
@ -344,6 +344,8 @@ kotlin {
|
|||||||
|
|
||||||
all {
|
all {
|
||||||
languageSettings.enableLanguageFeature("InlineClasses")
|
languageSettings.enableLanguageFeature("InlineClasses")
|
||||||
|
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||||
|
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +269,8 @@ kotlin {
|
|||||||
|
|
||||||
all {
|
all {
|
||||||
languageSettings.enableLanguageFeature("InlineClasses")
|
languageSettings.enableLanguageFeature("InlineClasses")
|
||||||
|
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||||
|
languageSettings.useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
package com.ionspin.kotlin.crypto.sample
|
package com.ionspin.kotlin.crypto.sample
|
||||||
|
|
||||||
object Sample {
|
import com.ionspin.kotlin.crypto.Crypto
|
||||||
fun blakehash() {
|
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.Blake2bDelegated
|
||||||
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2bStateless
|
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.ExperimentalTime
|
||||||
import kotlin.time.measureTime
|
import kotlin.time.measureTime
|
||||||
|
|
||||||
@ExperimentalTime
|
@ExperimentalTime
|
||||||
@ExperimentalStdlibApi
|
@ExperimentalStdlibApi
|
||||||
fun main() {
|
fun main() = runBlocking {
|
||||||
println("Test")
|
Sample.runSample()
|
||||||
// Blake
|
// println("Test")
|
||||||
val blake = Blake2bDelegated()
|
//// Blake
|
||||||
val res = blake.digest()
|
// val blake = Blake2bDelegated()
|
||||||
println("Result of res")
|
// val res = blake.digest()
|
||||||
// println(res)
|
// println("Result of res")
|
||||||
val staticRes = Blake2bStateless.digest("test")
|
//// println(res)
|
||||||
println("Result:")
|
// val staticRes = Blake2bStateless.digest("test")
|
||||||
println(staticRes)
|
// println("Result:")
|
||||||
|
// println(staticRes)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user