Java tutorial
//package com.java2s; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; public class Main { private static byte[] iv() { byte[] iv = null; try { KeyGenerator kgen = KeyGenerator.getInstance("AES"); kgen.init(128); SecretKey skey = kgen.generateKey(); iv = skey.getEncoded(); } catch (Exception e) { e.printStackTrace(); } return iv; } }