libsodium on LiveCode?
brian at milby7.com
Tue Feb 20 00:44:19 EST 2018
I was finally able to get the init to return a 0 or 1 (success or already
initialized). I switched to `code\x86-win` - not sure if that had any
effect based on the other major change I made...
Turns out I was using the wrong version of the dll. If anyone else wants
to try, here's the path that actually worked:
other files there that I included as well)
I was initially trying a different archive, but then switched to the msvc
version. I started with v141 which didn't work. I went ahead and tried
v100 which did. There are also v110, v120, and v140. I don't know what
the differences are, but at this point am just happy that I can get the
library initialized. I'll eventually try others and try to figure out what
the numbers mean.
@Monte, I was using __safe based on a thread that Mark W commented in on
the forum. Essentially if the library is returning just an integer then it
would probably be safe.
Thanks on the hints on sending data to the library. I'm also going to need
to receive keys back from the library. I'm guessing that where it is
listed as pK that it will overwrite the data in the passed in string.
There are other calls that use a pointer and a length as separate arguments
to the function, so the calls provided will be useful there (those are for
encrypting/decrypting content). I'll probably need to dive into the source
to understand that a bit more (unless their api docs cover it).
Now that I can actually talk to the code, I should be able to experiment.
Here's something that I got working to return the version:
private __safe foreign handler _sodium_library_version_major() returns CInt
binds to "c:libsodium>sodium_library_version_major"
private __safe foreign handler _sodium_library_version_minor() returns CInt
binds to "c:libsodium>sodium_library_version_minor"
public handler sodiumVersion() returns String
variable tResult as String
put "Version " into tResult
put _sodium_library_version_major() formatted as string after tResult
put "." after tResult
put _sodium_library_version_minor() formatted as string after tResult
return tResult --"Version 10.1"
More information about the Use-livecode