如何添加bouncycastle算法到android [英] how to add bouncycastle algorithm to android

查看:159
本文介绍了如何添加bouncycastle算法到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

我虽然bouncycastle没有提供与Android 1.6 SDK,所以想到单独安装。我该怎么办?
如果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中,选择项目 - >属性,然后选择Java构建路径。然后单击添加外部Jars,导航到您放置.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.

现在键入或粘贴一些尝试使用类的代码罐子如果你幸运的话,左边缘会出现一个灯泡图标。点击此按钮将提示您将正确的导入语句添加到.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.

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

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