I'm creating an AES key using the KeyGenerator
class. Then I exposed a web service to do encryption and decryption using this AES key and return the cipher text/plain text in web service response.
Encryption is working perfectly fine but when I call the web service (from SOAP UI) for decryption, I'm getting javax.crypto.BadPaddingException: Given final block not properly padded
exception intermittently.
I'm using hexadecimal (using the org.apache.commons.codec.binary.Hex
class) encoding/decoding to convert bytes in to String
and vice versa.
I created a standalone class to test this code and working without any issues.
Any thoughts on how to resolve this issue?