code: public static byte[] generateKey(String keyType, int keyLength) throws NoSuchAlgorithmException {
          KeyGenerator generator = KeyGenerator.getInstance(keyType);
          generator.init(keyLength);
          return generator.generateKey().getEncoded();
      }
docs: Generate a new AES key used to encrypt the message.
  
  @param keyType Key Type
  @param keyLength Key Length in bit
  @return new AES key
  @throws NoSuchAlgorithmException