如何将 Bouncy Castle 算法添加到 Android? [英] How to add Bouncy Castle algorithm to Android?

查看:22
本文介绍了如何将 Bouncy Castle 算法添加到 Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 bouncycastle 算法编写一个小应用程序,来自 BouncyCastleProvider.java 它说我们必须在运行时通过以下代码导入和添加提供程序

I am trying to write a small application using bouncycastle algorithm, from the BouncyCastleProvider.java it says we have to import and add the provider during runtime by the following code

import org.bouncycastle.jce.provider.BouncyCastleProvider;Security.addProvider(new BouncyCastleProvider());

错误 - 无法解析导入 org.bouncycastle;进口期间错误 - BouncyCastleProvider 无法解析为类型;调用 addProvider 时

error - The import org.bouncycastle cannot be resolved; during import error - BouncyCastleProvider cannot be resolved to a type; when calling addProvider

我虽然 Android 1.6 SDK 没有提供 bouncycastle,所以想单独安装.我该怎么做?如果 Bouncycastle 与 SDK 一起提供,我应该怎么做才能避免这些错误?我在 winXP 上使用 Android 1.6,eclipse-V3.4.0.提前致谢

I though bouncycastle is not provided with the Android 1.6 SDK, so thought of installing separately. how should i do this? If Bouncycastle is shipped along with SDK, what should i do to avoid these errors? I am using Android 1.6, eclipse-V3.4.0 on winXP . Thanks in advance

推荐答案

我不熟悉这个特定的库.但是,这里是关于如何将作为jar"文件交付的库包含到 Android 项目中的一般说明.

I'm not familiar with this particular library. However, here are general instructions on how to include a library delivered as a 'jar' file into an Android project.

下载 jar 文件并将其放在工作站上的某个位置.您可能希望将其放在要安装它的项目的根目录中,或者放在根目录中的lib"目录中.

Download the jar file and put it somewhere on your workstation. You may want to put in the root directory of the project your are installing it in, or maybe in a 'lib' directory in the root.

在 Eclipse 中,选择 Project->Properties,然后选择 Java Build Path.然后单击添加外部罐子,导航到您放置 .jar 文件的位置,选择它并单击打开.

In Eclipse, select Project->Properties, then select Java Build Path. Then click Add External Jars, navigate to where you put the .jar file, select it and click Open.

现在输入或粘贴一些尝试使用 jar 中的类的代码.如果幸运的话,左边缘会出现一个灯泡图标.单击此按钮将提示您将正确的导入语句添加到 .java 文件的顶部.

Now type or paste some code that attempts to use the classes in the jar. If you are lucky a light bulb icon will appear in the left margin. Clicking on this will prompt you to add the correct Import statement to the top of your .java file.

此时仍有可能出错.该库可能会使用 Android 未提供的 java.* 或 javax.* 内容(它只有这些库的一个子集).它也可能有自己的附加库依赖项..jar 可能与 Android 平台不兼容还有其他原因.

There are still things that can go wrong at this point. The library may make use of java.* or javax.* content not supplied by Android (it has just a subset of these libraries). Also it may have additional library dependencies of its own. There are other reasons why the .jar may not be compatible with the Android platform.

另请注意,它会增加 .apk 的大小以容纳新内容.

Note also that it will increase the size of your .apk to accommodate the new content.

这篇关于如何将 Bouncy Castle 算法添加到 Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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