密码学 - Java 1.4 中的 RSA 算法

发布于 2024-09-06 20:55:33 字数 398 浏览 7 评论 0原文

我正在使用 Java 1.4.2_10,并且尝试使用 RSA 加密:

我收到以下代码的 NoSuchAlgorithmException:

cipher = Cipher.getInstance("RSA");

这是错误:

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA
        at javax.crypto.Cipher.getInstance(DashoA6275)

这在 1.5 及更高版本中工作正常,但我需要使用 1.4。是否有任何解决方法或第三方产品可以用来解决此问题?

提前致谢。

I am using Java 1.4.2_10 and I am trying to use RSA encryption:

I am getting the NoSuchAlgorithmException for the following code:

cipher = Cipher.getInstance("RSA");

This is the error:

java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA
        at javax.crypto.Cipher.getInstance(DashoA6275)

This works fine in 1.5 and above, however I need to use 1.4. Is there any workaround or thirdparty product that I can use to fix this?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长梦不多时 2024-09-13 20:55:33

您可以安装 Bouncy Castle 加密提供程序。只需抓住他们的罐子,然后调用 Cipher.getInstance("RSA", "BC")

You can install the Bouncy Castle cryptography provider. Just grab their jars and then call Cipher.getInstance("RSA", "BC")

素年丶 2024-09-13 20:55:33

Java 1.4 绝对支持 RSA,所以这不起作用的事实表明更深层次的问题是错误的。这是否适用于任何其他密码(例如“AES”或“DES”)?您应该检查以确保您的提供商配置正确。以下代码在您的系统上的输出是什么:

System.out.println("Providers: ");
java.security.Provider[] providers =  java.security.Security.getProviders();
for(int x = 0; x < providers.length; x++) {
    System.out.println("\t" + providers[x]);
}

System.out.println();
System.out.println("Algorithms: ");
java.util.Set algs = java.security.Security.getAlgorithms("Cipher");

java.util.Iterator i_algs = algs.iterator(); 
while(i_algs.hasNext()) {
    System.out.println("\t" + i_algs.next());
}

Java 1.4 definitely supports RSA, so the fact that this isn't working suggests that something deeper is wrong. Does this work with any other ciphers (such as "AES" or "DES")? You should check to make sure your providers are properly configured. What is the output of the following code on your system:

System.out.println("Providers: ");
java.security.Provider[] providers =  java.security.Security.getProviders();
for(int x = 0; x < providers.length; x++) {
    System.out.println("\t" + providers[x]);
}

System.out.println();
System.out.println("Algorithms: ");
java.util.Set algs = java.security.Security.getAlgorithms("Cipher");

java.util.Iterator i_algs = algs.iterator(); 
while(i_algs.hasNext()) {
    System.out.println("\t" + i_algs.next());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文