本文介绍了android eclipse jedisct1 / libsodium从哪里开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要执行libsodium加密的程序。我发现这个图书馆
,但我认为它需要与NDK一起使用。所以我开始阅读有关NDK的教程,但是我仍然不知道从哪里开始使用这个库。如果有人可以给出一个提示或非常有用的东西来提供如何整合这个图书馆的想法,我会很开心。



谢谢

解决方案

要将libsodium整合到您的Android应用程序中,您需要:




  • 为您的Android平台编译的libsodium库

  • JNI绑定如



如果您信任互联网上的随机人员(您不应该!),请下载并将其解压缩到您的项目源中。否则,请按照以下说明自行编译。



libsodium



您需要一个Linux盒/ VM Android NDK来编译libsodium共享库,并且您似乎需要使用当前的git主分支来使用NDK进行编译。一旦检查出来,编译ARM,ARMv7和x86的Android库代码:

  ./ autogen.sh $ b $对于较旧的ARMv6设备,b ./dist-build/android-arm.sh#对于最近的ARMv7设备,
./dist-build/android-armv7-a.sh#
./dist-build /android-x86.sh#用于模拟器/ x86设备
#提供目录名称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



kalium-jni



要编译kalium,您需要已安装。然后,您需要生成SWIG C包装器,为目标平台编译libkaliumjni本机代码,将其安装到您的应用程序库/目录中并包含JAR。



在kalium-jni / jni子目录中,为您的主机创建SWIG包装器和本机libkaliumjni.so(它将用于测试JAR):

  ./ compile.sh 

之后,修改 jni / Android.mk ,并将 / installs / 替换为编译libsodium的地方, $ TARGET_ARCH) $(TARGET_ARCH_ABI)然后在kalium-jni目录中运行:

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

现在 libs / code>目录包含本机kalium库。



最后,您需要编译kalium JAR:

  mvn clean install 

应该以〜 /.m2/repository/org/abstractj/kalium/kalium-jni/1.0.0-SNAPSHOT/kalium-jni-1.0.0-SNAPSHOT.jar 。将它复制到您的 libs 目录中。它伴随着javadoc和源JAR,您可以添加到Eclipse中以获取引用。


I have a program that needs to execute a libsodium encryption. I found this library libsodiumbut I think it needs to be used with NDK. And so I started to read tutorials about NDK but I still don't know where to start on using this library. If someone could give a hint or very useful stuff to give an idea on how to integrate this library, I would be so happy.

Thanks

解决方案

To integrate libsodium into your Android app, you need:

  • The libsodium library compiled for your Android platform(s)
  • A JNI binding like kalium-jni

If you trust random people on the Internet (which you should not!), download this tarball and extract it into your project source. Otherwise, follow the instructions below to compile it yourself.

libsodium

You need a Linux box/VM with Android NDK to compile the libsodium shared libraries, and it seems like you need the current git master branch to compile it with the NDK. Once you checked it out, 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

kalium-jni

To compile kalium, you will need SWIG installed. Then, you need to generate the SWIG C wrapper, compile the libkaliumjni native code for your target platform(s), install it into your app libs/ directory and include the JAR.

In the kalium-jni/jni sub-directory, create the SWIG wrapper and the native libkaliumjni.so for your host (it will be needed for testing the JAR):

./compile.sh

Afterwards, modify jni/Android.mk and replace /installs/ with wherever you have compiled libsodium, and $(TARGET_ARCH) with $(TARGET_ARCH_ABI) then run in the kalium-jni 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

Now the libs/ directory contains the native kalium libraries. Copy it into your Android project.

Finally, you need to compile the kalium JAR:

mvn clean install

It should end up in ~/.m2/repository/org/abstractj/kalium/kalium-jni/1.0.0-SNAPSHOT/kalium-jni-1.0.0-SNAPSHOT.jar. Copy that to your libs directory as well. It is accompanied by javadoc and sources JARs, which you can add into Eclipse to get the references.

这篇关于android eclipse jedisct1 / libsodium从哪里开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 22:20