unity.libsodium icon indicating copy to clipboard operation
unity.libsodium copied to clipboard

Add WebGL target

Open jasonboukheir opened this issue 1 year ago • 1 comments

I've been struggling to get WebGL crypto functions to work in my Algorand SDK library. I have been using .jslib native plugins to handle them, but the APIs are not the same as libsodium.

Well I'm pleased to show off that I got source libsodium working in WebGL! Check this out: https://github.com/CareBoo/unity-algorand-sdk/tree/8c1b360d745cfcb1d621d355f56fa959c33a8957/Runtime/Algorand.Unity.Crypto/Plugins/WebGL

I have only tested ChaCha20Poly1305, Ed25519, and Sha512, however, I'm really surprised it worked!

So the steps to copy from the libsodium project were the following:

  1. Give each file a unique name.
  2. Replace all #includes with the new names.
  3. Flatten the folders.
  4. Remove all directories from #includes.
  5. Set explicit version and minimal in the version.h.in -> version.h file.

I recommend doing something similar to add this to WebGL. It should also just work for any platform using IL2CPP, so it opens this project up to loads of other platforms!

jasonboukheir avatar Aug 06 '23 06:08 jasonboukheir