android eclipse jedisct1/libsodium 从哪里开始

android eclipse jedisct1/libsodium where to start(android eclipse jedisct1/libsodium 从哪里开始)
本文介绍了android eclipse 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 集成到您的 Android 应用中,您需要:

To integrate libsodium into your Android app, you need:

  • 为您的 Android 平台编译的 libsodium 库
  • 一个 JNI 绑定,例如 kalium-jni

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

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.

您需要一个带有 Android NDK 的 Linux 机器/VM 来编译 libsodium 共享库,而且您似乎需要当前的 git master 分支来使用 NDK 编译它.确认后,为 ARM、ARMv7 和 x86 编译 Android 库代码:

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

要编译 kalium,您需要安装 SWIG.然后,您需要生成 SWIG C 包装器,为您的目标平台编译 libkaliumjni 本机代码,将其安装到您的应用程序 libs/目录并包含 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.

在 kalium-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 并将 /installs/ 替换为您编译 libsodium 的位置,并将 $(TARGET_ARCH) 替换为$(TARGET_ARCH_ABI) 然后在kalium-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

现在 libs/ 目录包含原生 kalium 库.将其复制到您的 Android 项目中.

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

最后,你需要编译 kalium JAR:

Finally, you need to compile the 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 中以获取参考.

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Creating RSA Public Key From String(从字符串创建 RSA 公钥)
Encrypt with Node.js Crypto module and decrypt with Java (in Android app)(使用 Node.js Crypto 模块加密并使用 Java 解密(在 Android 应用程序中))
How to hash a string in Android?(如何在Android中对字符串进行哈希处理?)
How to validate Safety Net JWS signature from header data in Android app(如何从 Android 应用程序中的标头数据验证 Safety Net JWS 签名)
How can I decode JWT token in android?(如何在 android 中解码 JWT 令牌?)
BitmapFactory﹕ Unable to decode stream - null(BitmapFactory:无法解码流 - null)