Here you can find the source of generateIV()
public static byte[] generateIV()
//package com.java2s; //License from project: Open Source License import java.security.SecureRandom; public class Main { private static final int IV_LENGTH = 16; /**/*from w ww . j ava 2 s.c om*/ * Randomly generates an initialization vector (IV) which can be used as parameter for symmetric * encryption. * * @return Returns a randomly generated IV. */ public static byte[] generateIV() { SecureRandom random = new SecureRandom(); byte[] iv = new byte[IV_LENGTH]; do { random.nextBytes(iv); } while (iv[0] == 0); return iv; } }