在 Java 程序中集成 Bouncy Castle 提供程序的最佳方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6442012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the best way to integrate the Bouncy Castle provider in a Java program?
提问by Pablosproject
What's the best way to integrate the Bouncy Castle provider in a Java program? I know I can add it programmatically, by using:
在 Java 程序中集成 Bouncy Castle 提供程序的最佳方法是什么?我知道我可以使用以下方法以编程方式添加它:
import org.bouncycastle.jce.provider.BouncyCastleProvider;
...
Security.addProvider(new BouncyCastleProvider());
Or either I can add it to a path in the JRE on my machine.
或者我可以将它添加到我机器上 JRE 的路径中。
What's the best choice?
最好的选择是什么?
采纳答案by Robert
In my opinion the adding it as security provider with own code is the best option. This is because it is only project dependent - not system dependent. Add the BouncyCastle jar file(s) to your project and add them to the class-path and that's it. It will work on all systems without need for further manual installation steps.
在我看来,将其添加为具有自己代码的安全提供者是最好的选择。这是因为它仅依赖于项目 - 不依赖于系统。将 BouncyCastle jar 文件添加到您的项目并将它们添加到类路径中,就是这样。它适用于所有系统,无需进一步的手动安装步骤。
If you install BouncyCastle into the JRE you always have problems in case you have to update the JRE.
如果您将 BouncyCastle 安装到 JRE 中,您总是会遇到问题,以防您必须更新 JRE。