Android eclipse jedisct1 / libsodium, where to start

I have a program that should do libsodium encryption. I found this libsodium library but I think it should be used with the NDK. And so I started reading NDK tutorials, but I still don't know where to start using this library. If someone can give a hint or very useful material to give an idea of ​​how to integrate this library, I would be so happy.

thanks

+6
source share
1 answer

To integrate libsodium into your Android application, you need:

  • The libsodium library compiled for your Android platform.
  • JNI binding e.g. kalium-jni

If you trust random people on the Internet (which you shouldn't!), Download this tarball and extract it to your project source. Otherwise, follow the instructions below to compile them yourself.

libsodium

You need a Linux / VM box with Android NDK to compile the libsodium shared libraries, and you think you need the current git branch to compile it with the NDK. After you have verified this, compile the Android library code for ARM, ARMv7, and x86:

./autogen.sh ./dist-build/android-arm.sh # for older ARMv6 devices ./dist-build/android-armv7-a.sh # for the more recent ARMv7 devices ./dist-build/android-x86.sh # for the emulator / x86 devices # Provide the directory names nkd-build expects ln -s libsodium-android-armv6 libsodium-android-armeabi ln -s libsodium-android-armv7-a libsodium-android-armeabi-v7a ln -s libsodium-android-i686 libsodium-android-x86 

potassium-jni

To compile potassium, you need SWIG . Then you need to generate the SWIG C shell, compile your own libkaliumjni code for your target platform (s), install it in the libs / application directory, and enable the JAR.

In the kalium-jni / jni subdirectory, create a SWIG shell and your own libkaliumjni.so for your host (you will need it for testing the JAR):

 ./compile.sh 

Then change jni/Android.mk and replace /installs/ with the one where you compiled libsodium and $(TARGET_ARCH) with $(TARGET_ARCH_ABI) , then run kalium-jni in the directory:

 ndk-build APP_ABI=armeabi,armeabi-v7a,x86 [...] [x86] Install : libkaliumjni.so => libs/x86/libkaliumjni.so [armeabi] Install : libkaliumjni.so => libs/armeabi/libkaliumjni.so [armeabi-v7a] Install : libkaliumjni.so => libs/armeabi-v7a/libkaliumjni.so 

The libs/ directory now contains its own kalium libraries. Copy it into your Android project.

Finally, you need to compile the callium JAR:

 mvn clean install 

It should be in ~/.m2/repository/org/abstractj/kalium/kalium-jni/1.0.0-SNAPSHOT/kalium-jni-1.0.0-SNAPSHOT.jar . Copy it to the libs directory. It is accompanied by javadoc and JAR sources, which you can add to Eclipse for links.

+10
source

Source: https://habr.com/ru/post/978009/


All Articles