Android的日食jedisct1 / libsodium从哪里开始 [英] android eclipse jedisct1/libsodium where to start

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

问题描述

我有需要执行libsodium加密的程序。我发现这个库 libsodium
但我认为它需要与NDK使用。于是我开始阅读关于NDK教程,但我还是不知道在哪里可以使用这个库开始。如果有人能给出提示还是很有用的东西就如何这个库集成了一个想法,我会很高兴。

I have a program that needs to execute a libsodium encryption. I found this library libsodium but 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.

感谢

推荐答案

要libsodium集成到您的Andr​​oid应用程序,您需要:

To integrate libsodium into your Android app, you need:


  • 的libsodium库编译你的Andr​​oid平台(S)

  • 系统JNI如钾,JNI
  • 绑定
  • 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.

您需要一台Linux机器/ VM与Android NDK编译libsodium共享库,它似乎像你需要在当前的git主分支与NDK进行编译。一旦你签出,编译了Android库code为ARM,ARMv7体系和x86:

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

钾-JNI

要编译钾,您需要痛饮安装。然后,你需要生成SWIG C包装,编译libkaliumjni本土code你的目标平台上,它安装到您的应用程序库/目录包括JAR。

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.

在钾,JNI / JNI子目录,创建SWIG包装和本机libkaliumjni.so为您的主机(这将需要测试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

之后,修改 JNI / Android.mk 和替换 /安装/ 与不管你编译libsodium和 $(TARGET_ARCH) $(TARGET_ARCH_ABI)然后在钾,JNI目录下运行:

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

现在的库/ 目录包含本地钾库。它复制到你的Andr​​oid项目。

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

最后,你需要编译钾JAR:

Finally, you need to compile the kalium JAR:

mvn clean install

这应该结束了在<$c$c>~/.m2/repository/org/abstractj/kalium/kalium-jni/1.0.0-SNAPSHOT/kalium-jni-1.0.0-SNAPSHOT.jar.复制到你的目录中。它是伴随着Javadoc和源代码的JAR文件,你可以加入到Eclipse中得到引用。

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的日食jedisct1 / libsodium从哪里开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆