Api cleanup
This commit is contained in:
1 parent
25adc330bd
commit
f03e94cf5e
15 files changed
+91
-83
No files matched your search
+1
-1
@@ -9,7 +9,7 @@ import org.khronos.webgl.Uint8Array
|
||||
*/
|
||||
interface JsSodiumInterface {
|
||||
|
||||
fun crypto_generichash(hashLength: Int, inputMessage: String) : Uint8Array
|
||||
fun crypto_generichash(hashLength: Int, inputMessage: Uint8Array) : Uint8Array
|
||||
|
||||
fun randombytes_buf(numberOfBytes: Int) : Uint8Array
|
||||
|
||||
|
||||
+11
-29
@@ -2,6 +2,7 @@ package com.ionspin.kotlin.crypto.hash.blake2b
|
||||
|
||||
import com.ionspin.kotlin.crypto.getSodium
|
||||
import com.ionspin.kotlin.crypto.util.toHexString
|
||||
import org.khronos.webgl.Uint8Array
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
@@ -33,36 +34,17 @@ actual class Blake2bDelegated actual constructor(key: UByteArray?, hashLength: I
|
||||
actual object Blake2bDelegatedStateless : Blake2bStateless {
|
||||
override val MAX_HASH_BYTES: Int = 64
|
||||
|
||||
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
|
||||
val hashed = getSodium().crypto_generichash(64, inputString)
|
||||
val hash = UByteArray(MAX_HASH_BYTES)
|
||||
for (i in 0 until MAX_HASH_BYTES) {
|
||||
js(
|
||||
"""
|
||||
hash[i] = hashed[i]
|
||||
"""
|
||||
)
|
||||
}
|
||||
println("Hash ${hash.toHexString()}")
|
||||
return hash
|
||||
}
|
||||
|
||||
fun digestBlocking(inputString: String, key: String?, hashLength: Int): UByteArray {
|
||||
val hashed = getSodium().crypto_generichash(hashLength, inputString)
|
||||
val hash = UByteArray(MAX_HASH_BYTES)
|
||||
for (i in 0 until MAX_HASH_BYTES) {
|
||||
js(
|
||||
"""
|
||||
hash[i] = hashed[i]
|
||||
"""
|
||||
)
|
||||
}
|
||||
println("Hash ${hash.toHexString()}")
|
||||
return hash
|
||||
}
|
||||
|
||||
override fun digest(inputMessage: UByteArray, key: UByteArray, hashLength: Int): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
val hashed = getSodium().crypto_generichash(64, Uint8Array(inputMessage.toByteArray().toTypedArray()))
|
||||
val hash = UByteArray(MAX_HASH_BYTES)
|
||||
for (i in 0 until MAX_HASH_BYTES) {
|
||||
js(
|
||||
"""
|
||||
hash[i] = hashed[i]
|
||||
"""
|
||||
)
|
||||
}
|
||||
return hash
|
||||
}
|
||||
|
||||
|
||||
|
||||
-3
@@ -23,9 +23,6 @@ actual class Sha256Delegated actual constructor(key: UByteArray?, hashLength: In
|
||||
}
|
||||
|
||||
actual object Sha256StatelessDelegated : StatelessSha256 {
|
||||
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
override fun digest(inputMessage: UByteArray, key: UByteArray, hashLength: Int): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
|
||||
-3
@@ -23,9 +23,6 @@ actual class Sha512Delegated actual constructor(key: UByteArray?, hashLength: In
|
||||
}
|
||||
|
||||
actual object Sha512StatelessDelegated : StatelessSha512 {
|
||||
override fun digest(inputString: String, key: String?, hashLength: Int): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
override fun digest(inputMessage: UByteArray, key: UByteArray, hashLength: Int): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
|
||||
Reference in new issue
Block a user