java.security.NoSuchAlgorithmException:找不到任何支持 AES/ECB/PKCS7PADDING 的提供程序 [英] java.security.NoSuchAlgorithmException:Cannot find any provider supporting AES/ECB/PKCS7PADDING

查看:47
本文介绍了java.security.NoSuchAlgorithmException:找不到任何支持 AES/ECB/PKCS7PADDING 的提供程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用 AES 算法加密数据.但是,发生了以下异常.

I was trying to encrypt data using AES algorithm. However, with the following exception has occurred.

java.security.NoSuchAlgorithmException:
    Cannot find any provider supporting AES/ECB/PKCS7PADDING

有人知道这个问题的解决方案吗?我的JDK版本是1.7.

Someone know a solution to this issue? My JDK's version is 1.7.

推荐答案

您不想为分组密码使用指定 PKCS#7 填充.您想指定 PKCS#5 填充.PKCS#5 被指定用于分组密码,而 PKCS#7 不是(它用于不同的地方,比如在 S/MIME 中).我会指出 PKCS#5 和 PKCS#7 实际上指定了完全相同的填充类型(它们是相同的!),但在此上下文中使用时称为 #5.:)

You don't want to specify PKCS#7 padding for block cipher use. You want to specify PKCS#5 padding. PKCS#5 is specified for use with block ciphers while PKCS#7 is not (it's use for different places like in S/MIME). I will point out that PKCS#5 and PKCS#7 actually specify exactly the same type of padding (they are the same!), but it's called #5 when used in this context. :)

因此,您需要 "AES/ECB/PKCS5PADDING" 而不是 "AES/ECB/PKCS7PADDING".这是一个密码实现,Java 平台的每个实现都需要支持.请参阅 Cipher 的文档类了解更多详情.

So, instead of "AES/ECB/PKCS7PADDING", you want "AES/ECB/PKCS5PADDING". This is a cipher implementation that every implementation of the Java platform is required to support. See the documentation of the Cipher class for more details.

这篇关于java.security.NoSuchAlgorithmException:找不到任何支持 AES/ECB/PKCS7PADDING 的提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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