probability or statistics – Computation of 1- and 2-sided p-values for Fisher’s Exact test for 2×2 table based on Monte Carlo

I am looking for code to compute the 1- and 2-sided p-value for Fisher’s Exact test for 2×2 tables based on Monte Carlo (bootstrap simulations).

For larger 2×2 crosstabulation tables, the exact p-value can often not be computed due to the large amount of computations.

Asymptotically p-values are often quite inaccurate.

Therefore, I would like to compute the p-values based on Monte Carlo.