Starting work on JS generator
This commit is contained in:
1 parent
a972b022d3
commit
1aaffe9c7c
4 files changed
+173
-4
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
package ext.libsodium.com.ionspin.kotlin.crypto
|
||||
|
||||
import org.khronos.webgl.Uint8Array
|
||||
import org.khronos.webgl.get
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
* ugljesa.jovanovic@ionspin.com
|
||||
* on 02-Aug-2020
|
||||
*/
|
||||
fun UByteArray.toUInt8Array() : Uint8Array {
|
||||
val uint8Result = Uint8Array(toByteArray().toTypedArray())
|
||||
return uint8Result
|
||||
}
|
||||
|
||||
|
||||
fun Uint8Array.toUByteArray() : UByteArray {
|
||||
val result = UByteArray(length)
|
||||
for (i in 0 until length) {
|
||||
result[i] = get(i).toUByte()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
Reference in new issue
Block a user