javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
时间: 2023-08-23 07:15:39 浏览: 404
回答: 引发javax.crypto.BadPaddingException异常的原因是在解密过程中使用了错误的密钥。\[1\]根据引用\[2\]的分析,当进行3DES加密时,如果最后一位不足64位,会自动补上,导致解密时报错。而引用\[3\]提供了一个DES解密的代码,其中在执行cipher.doFinal()时报错BadPaddingException。为了解决这个问题,有两种方法可供选择。一种是不使用openjdk,另一种是检查密钥是否正确。
#### 引用[.reference_title]
- *1* *3* [javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a](https://blog.csdn.net/kangweijian/article/details/127570890)[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^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [DES解码报错:javax.crypto.BadPaddingException: Given final block not properly padded](https://blog.csdn.net/moli8314/article/details/97025479)[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^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文