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.encodeToUByteArray
|
||||||
import com.ionspin.kotlin.crypto.util.testBlocking
|
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||||
import com.ionspin.kotlin.crypto.util.toHexString
|
import com.ionspin.kotlin.crypto.util.toHexString
|
||||||
import com.ionspin.kotlin.crypto.util.runTest
|
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
@ -17,7 +16,6 @@ class SmokeTest {
|
|||||||
//TODO Browser ignores our testBlocking, node works fine though
|
//TODO Browser ignores our testBlocking, node works fine though
|
||||||
@Test
|
@Test
|
||||||
fun testIfLibraryIsNotOnFire() {
|
fun testIfLibraryIsNotOnFire() {
|
||||||
throw Exception("aoaoao")
|
|
||||||
testBlocking {
|
testBlocking {
|
||||||
LibsodiumInitializer.initialize()
|
LibsodiumInitializer.initialize()
|
||||||
val hashResult = GenericHash.genericHash("Hello".encodeToUByteArray(), 64)
|
val hashResult = GenericHash.genericHash("Hello".encodeToUByteArray(), 64)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package ext.libsodium.com.ionspin.kotlin.crypto
|
package ext.libsodium.com.ionspin.kotlin.crypto
|
||||||
|
|
||||||
|
|
||||||
import com.ionspin.kotlin.crypto.box.BoxKeyPair
|
|
||||||
import org.khronos.webgl.Uint8Array
|
import org.khronos.webgl.Uint8Array
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,9 +10,13 @@ import org.khronos.webgl.Uint8Array
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@JsModule("libsodium-wrappers-sumo")
|
@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")
|
@JsName("crypto_generichash")
|
||||||
fun crypto_generichash(hashLength: Int, inputMessage: Uint8Array, key: Uint8Array): Uint8Array
|
fun crypto_generichash(hashLength: Int, inputMessage: Uint8Array, key: Uint8Array): Uint8Array
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.ionspin.kotlin.crypto
|
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.JsSodiumInterface
|
||||||
import ext.libsodium.com.ionspin.kotlin.crypto.JsSodiumLoader
|
import ext.libsodium.com.ionspin.kotlin.crypto.JsSodiumLoader
|
||||||
|
|
||||||
var sodiumLoaded: Boolean = false
|
var sodiumLoaded: Boolean = false
|
||||||
|
|
||||||
fun getSodium() : JsSodiumInterface = JsSodiumInterface
|
fun getSodium() : JsSodiumInterface = JsSodium.default
|
||||||
|
|
||||||
fun getSodiumLoaded() : Boolean = sodiumLoaded
|
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.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() {
|
fun main() {
|
||||||
LibsodiumInitializer.initializeWithCallback {
|
LibsodiumInitializer.initializeWithCallback {
|
||||||
// val hash = Hash.sha512("123".encodeToUByteArray())
|
val hash = Hash.sha512("123".encodeToUByteArray())
|
||||||
// println("Hash (SHA512) of 123: ${hash.toHexString()}")
|
println("Hash (SHA512) of 123: ${hash.toHexString()}")
|
||||||
println("Hello")
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user