Here you can find the source of generateKey()
public static byte[] generateKey()
//package com.java2s; //License from project: Apache License import java.security.NoSuchAlgorithmException; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; public class Main { public static byte[] generateKey() { try {/*from www. j ava2s .c o m*/ KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); keyGenerator.init(128); SecretKey key = keyGenerator.generateKey(); return key.getEncoded(); } catch (NoSuchAlgorithmException e) { } return null; } }