public static SecretKey generateKey(String key,String algorithm) throws EncodingException {
  try {
    SecretKey skey=new SecretKeySpec(key.getBytes("UTF-8"),algorithm);
    return skey;
  }
 catch (  Exception e) {
    throw new EncodingException(e);
  }
}

public static SecretKey generateKey ( String key , String algorithm ) throws EncodingException { try { SecretKey skey = new SecretKeySpec ( key . getBytes ( "UTF-8" ) , algorithm ) ; return skey ; } catch ( Exception e ) { throw new EncodingException ( e ) ; } }
generate a key based on the provided secret .
