We are trying to validate the user emails by sending an encrypted token with the email. In some occasions, it gives:
javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
The thing is, we have a key and we are not giving IvParameterSpec a random number but a static one. I know it is not safe but, if we randomize, it does not decrypt the token when the process is restarted and such. At least the first 16 characters are not being decrypted which makes the functionality failed. Saving IVSpec is not an option also.
Any ideas what is the core of this problem? Or an alternative way to securely enc-dec in case of process restart?