Sample (and maybe something else too, idk) works now!!
This commit is contained in:
parent
e2a079f0d2
commit
083df8a73c
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,6 @@ import com.ionspin.kotlin.crypto.generichash.GenericHash
|
||||
import com.ionspin.kotlin.crypto.util.encodeToUByteArray
|
||||
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||
import com.ionspin.kotlin.crypto.util.toHexString
|
||||
import com.ionspin.kotlin.crypto.util.runTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@ -17,7 +16,6 @@ class SmokeTest {
|
||||
//TODO Browser ignores our testBlocking, node works fine though
|
||||
@Test
|
||||
fun testIfLibraryIsNotOnFire() {
|
||||
throw Exception("aoaoao")
|
||||
testBlocking {
|
||||
LibsodiumInitializer.initialize()
|
||||
val hashResult = GenericHash.genericHash("Hello".encodeToUByteArray(), 64)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ext.libsodium.com.ionspin.kotlin.crypto
|
||||
|
||||
|
||||
import com.ionspin.kotlin.crypto.box.BoxKeyPair
|
||||
import org.khronos.webgl.Uint8Array
|
||||
|
||||
/**
|
||||
@ -11,9 +10,13 @@ import org.khronos.webgl.Uint8Array
|
||||
*/
|
||||
|
||||
@JsModule("libsodium-wrappers-sumo")
|
||||
external object JsSodiumInterface {
|
||||
|
||||
external object JsSodium: JsAny {
|
||||
@JsName("default")
|
||||
val default : JsSodiumInterface
|
||||
}
|
||||
|
||||
@JsModule("libsodium-wrappers-sumo")
|
||||
external object JsSodiumInterface: JsAny {
|
||||
@JsName("crypto_generichash")
|
||||
fun crypto_generichash(hashLength: Int, inputMessage: Uint8Array, key: Uint8Array): Uint8Array
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.ionspin.kotlin.crypto
|
||||
|
||||
import ext.libsodium.com.ionspin.kotlin.crypto.JsSodium
|
||||
import ext.libsodium.com.ionspin.kotlin.crypto.JsSodiumInterface
|
||||
import ext.libsodium.com.ionspin.kotlin.crypto.JsSodiumLoader
|
||||
|
||||
var sodiumLoaded: Boolean = false
|
||||
|
||||
fun getSodium() : JsSodiumInterface = JsSodiumInterface
|
||||
fun getSodium() : JsSodiumInterface = JsSodium.default
|
||||
|
||||
fun getSodiumLoaded() : Boolean = sodiumLoaded
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
config.resolve.alias = {
|
||||
"crypto": false,
|
||||
// "path": false,
|
||||
}
|
@ -1,12 +1,15 @@
|
||||
|
||||
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer
|
||||
import com.ionspin.kotlin.crypto.getSodium
|
||||
import com.ionspin.kotlin.crypto.hash.Hash
|
||||
import com.ionspin.kotlin.crypto.util.encodeToUByteArray
|
||||
import ext.libsodium.com.ionspin.kotlin.crypto.JsSodiumInterface
|
||||
|
||||
|
||||
fun main() {
|
||||
LibsodiumInitializer.initializeWithCallback {
|
||||
// val hash = Hash.sha512("123".encodeToUByteArray())
|
||||
// println("Hash (SHA512) of 123: ${hash.toHexString()}")
|
||||
println("Hello")
|
||||
}
|
||||
LibsodiumInitializer.initializeWithCallback {
|
||||
val hash = Hash.sha512("123".encodeToUByteArray())
|
||||
println("Hash (SHA512) of 123: ${hash.toHexString()}")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user