java.lang.IllegalStateException: Unable to invoke Cipher due to bad padding

Hot problem!
This exception has a lot of traffic. You can help 18 users by writing a short tip.

Searched on Google with the first line of a JAVA stack trace?

We can recommend more relevant solutions and speed up debugging when you paste your entire stack trace with the exception message. Try a sample exception.

Recommended solutions based on your search

Solutions on the web

via Stack Overflow by user1134179
, 1 year ago
Unable to invoke Cipher due to bad padding
via Spring JIRA by Jasvinder Bahra, 1 year ago
Unable to invoke Cipher due to bad padding
via GitHub by guptalav108
, 8 months ago
Unable to invoke Cipher due to bad padding
via GitHub by checketts
, 1 year ago
javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811)
at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676)
at com.sun.crypto.provider.AESCipher.engineDoFinal(AESCipher.java:313)
at javax.crypto.Cipher.doFinal(Cipher.java:2087)
at org.springframework.security.crypto.encrypt.CipherUtils.doFinal(CipherUtils.java:135)
at com.test.encryption.MyTest.crypt(MyTest.java:45)
at com.test.encryption.MyTest.decryptFile(MyTest.java:31)
at com.test.encryption.MyTest.main(MyTest.java:21)

Users with the same issue

3 times, 1 year ago
93 times, 1 year ago
2 times, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 7 months ago
Samebug visitor profile picture
Unknown user
Once, 7 months ago

Write tip

Know the solutions? Share your knowledge to help other developers to debug faster.