private String generateKey() throws Exception {
  KeyGenerator keyGenerator=KeyGenerator.getInstance("AES");
  keyGenerator.init(128);
  SecretKey secretKey=keyGenerator.generateKey();
  byte[] keyInBytes=secretKey.getEncoded();
  String key=Base64.encode(keyInBytes);
  return key;
}

private String generateKey ( ) throws Exception { KeyGenerator keyGenerator = KeyGenerator . getInstance ( "AES" ) ; keyGenerator . init ( 128 ) ; SecretKey secretKey = keyGenerator . generateKey ( ) ; byte [ ] keyInBytes = secretKey . getEncoded ( ) ; String key = Base64 . encode ( keyInBytes ) ; return key ; }
method generates key using advanced encryption standard algorithm .
