Android Aes Encryption Pad Block Corrupted
I am using the methods below and if I enter the right key everything works fine. But if I enter a wrong key I am receiving a BadPaddingException:pad block corrupted... Am I doing
Solution 1:
You're not doing anything wrong. It's expected. This is technically a duplicate of Java Encryption issue (which doesn't seem to be easy to find). See this answer for a good explanation. You can consider adding a MAC (Message Authentication Code) to safely accomplish something more like a checksum.
Solution 2:
Other than supplying the wrong key, I don't think so :)
A stack trace would help, so we can see which function is throwing the BadPaddingException.
This may well be because the 'bad' key is a different length to the 'good' key - does the 'bad' key come out of initKey() or somewhere else?
Best wishes,
Phil Lello
Post a Comment for "Android Aes Encryption Pad Block Corrupted"