public static SecretKey generateKey(String algorithm) throws EncodingException {
  try {
    KeyGenerator kgen=KeyGenerator.getInstance(algorithm);
    kgen.init(128);
    SecretKey key=kgen.generateKey();
    return key;
  }
 catch (  Exception e) {
    throw new EncodingException(e);
  }
}

public static SecretKey generateKey ( String algorithm ) throws EncodingException { try { KeyGenerator kgen = KeyGenerator . getInstance ( algorithm ) ; kgen . init ( 128 ) ; SecretKey key = kgen . generateKey ( ) ; return key ; } catch ( Exception e ) { throw new EncodingException ( e ) ; } }
generate a 128 bit key using the key generator of the algorithm provided .
