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

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

问题描述

我正在尝试从

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

导入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中,选择项目"->属性",然后选择"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.

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

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

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