protected SecretKey generateSecretKey(String algorithm,int keyStrength) throws EncryptionException {
  try {
    KeyGenerator keygen=KeyGenerator.getInstance(algorithm);
    if (keyStrength != 0) {
      keygen.init(keyStrength);
    }
    return keygen.generateKey();
  }
 catch (  NoSuchAlgorithmException ne) {
    throw new EncryptionException(ne);
  }
}

protected SecretKey generateSecretKey ( String algorithm , int keyStrength ) throws EncryptionException { try { KeyGenerator keygen = KeyGenerator . getInstance ( algorithm ) ; if ( keyStrength != 0 ) { keygen . init ( keyStrength ) ; } return keygen . generateKey ( ) ; } catch ( NoSuchAlgorithmException ne ) { throw new EncryptionException ( ne ) ; } }
generates secret key for a given algorithm and key strength .
