You don’t want to specify PKCS#7 padding for block cipher use. You want to specify PKCS#5 padding. PKCS#5 is specified for use with block ciphers while PKCS#7 is not (it’s use for different places like in S/MIME). I will point out that PKCS#5 and PKCS#7 actually specify exactly the same type of padding (they are the same!), but it’s called #5 when used in this context. 🙂
So, instead of "AES/ECB/PKCS7PADDING"
, you want "AES/ECB/PKCS5PADDING"
. This is a cipher implementation that every implementation of the Java platform is required to support. See the documentation of the Cipher
class for more details.