问题描述
我试图使用AES算法加密数据。但是,发生以下异常。
java.security.NoSuchAlgorithmException:
找不到任何提供者支持AES / ECB / PKCS7PADDING
有人知道这个问题的解决方案?
我的JDK的版本是1.7。
你不想指定PKCS#7填充块密码使用。你想指定PKCS#5填充。 PKCS#5被指定用于块密码,而PKCS#7不是(它用于不同的地方,如S / MIME中)。我将指出,PKCS#5和PKCS#7实际上指定了完全相同类型的填充(它们是一样的!),但是在这个上下文中使用时它被称为#5。所以,而不是AES / ECB / PKCS7PADDING
,您需要 AES / ECB / PKCS5PADDING
。这是一个加密实现,需要Java平台的每个实现来支持。请参阅了解更多详情。
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
Someone know a solution to this issue?My JDK's version is 1.7.
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. :)
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的提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!