I needed some simple string encryption, so I wrote the following code (with a great deal of \"inspiration\" from here):
// create and initialize a crypto
The answer updated by the user "atconway" worked for me.
The problem was not with the padding but the key which was different during encryption and decryption. The key and iv should be same during encypting and decrypting the same value.