IV length is a function of the encryption algorithm. For example, this will break with Blowfish which is an 8-bit block cipher. Not sure it's a big deal since most everyone will use AES, which has a 16-bit block, but wanted to point out. You can easily set the IV length by basing it on Cipher#getBlockSize().