public static SecretKey generateSecretKey(SecretKeyType secretKeyType,int keySize) throws CryptoException {
  try {
    KeyGenerator keyGenerator=KeyGenerator.getInstance(secretKeyType.jce(),BOUNCY_CASTLE.jce());
    keyGenerator.init(keySize,SecureRandom.getInstance("SHA1PRNG"));
    return keyGenerator.generateKey();
  }
 catch (  GeneralSecurityException ex) {
    throw new CryptoException(MessageFormat.format(res.getString("NoGenerateSecretKey.exception.message"),secretKeyType),ex);
  }
}

public static SecretKey generateSecretKey ( SecretKeyType secretKeyType , int keySize ) throws CryptoException { try { KeyGenerator keyGenerator = KeyGenerator . getInstance ( secretKeyType . jce ( ) , BOUNCY_CASTLE . jce ( ) ) ; keyGenerator . init ( keySize , SecureRandom . getInstance ( "SHA1PRNG" ) ) ; return keyGenerator . generateKey ( ) ; } catch ( GeneralSecurityException ex ) { throw new CryptoException ( MessageFormat . format ( res . getString ( "NoGenerateSecretKey.exception.message" ) , secretKeyType ) , ex ) ; } }
generate a secret key .
