java Input length must be multiple of 16 when decrypting with padded cipher
时间: 2023-12-08 14:38:52 浏览: 61
根据引用[1]中的错误提示信息,当使用填充密码解密时,输入长度必须是8的倍数。这通常是因为加密时使用了块密码模式,例如AES,而块密码模式要求输入长度必须是块大小的倍数。因此,如果输入长度不是块大小的倍数,则需要使用填充来填充输入以满足块大小的要求。
解决此问题的方法是确保输入长度是块大小的倍数。如果您正在使用填充,请确保填充的长度是正确的。如果您正在使用不同的块密码模式,请确保输入长度符合所选模式的要求。
如果您无法更改输入长度,则可以尝试使用无填充模式,例如ECB模式。但是,请注意,ECB模式不是安全的块密码模式,因为它不会隐藏明文中的模式。
相关问题
AES解密的时候报 Input length must be multiple of 16 when decrypting with padded cipher
这个异常是由于AES解密时输入的长度不是16的倍数导致的。根据引用\[1\]和引用\[2\]的信息,AES加密算法要求密钥必须是16位的,并且待加密内容的长度必须是16的倍数。如果不满足这些条件,就会出现这个异常。根据引用\[3\]的描述,你在解密时可能遇到了字符转义的问题,导致输入的长度不是16的倍数。你可以检查一下传参的内容是否正确,并确保输入的长度是16的倍数,这样就可以解决这个异常了。
#### 引用[.reference_title]
- *1* *2* [JAVA实现AES 解密报错Input length must be multiple of 16 when decrypting with padded cipher](https://blog.csdn.net/fragrant_no1/article/details/84402147)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [AES解密报错,Input length must be multiple of 16 when decrypting with padded cipher](https://blog.csdn.net/weixin_48207312/article/details/125638596)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
Input length must be multiple of 16 when decrypting with padded cipher
As an AI language model, I can tell you that this error message appears when you are trying to decrypt data that has been encrypted using a padding scheme, such as PKCS#7 or ISO/IEC 7816-4. Padding is used to ensure that the data being encrypted is a multiple of the block size of the cipher being used, which is typically 16 bytes for many block ciphers.
When you decrypt the data, the padding needs to be removed in order to obtain the original plaintext. However, if the input length is not a multiple of 16 bytes, it means that the padding has not been applied correctly or has been corrupted in some way.
To resolve this error, you should check that the data being decrypted is the same length as the original plaintext, minus any padding that may have been added. You should also check that the padding scheme used for encryption is compatible with the decryption algorithm being used.