export function generatePassword(length: number) {
  if (typeof crypto === "undefined") {
    throw new Error(
      "Crypto API is not supported. Please upgrade your web browser",
    );
  }

  const charset =
    "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

  const indexes: any = crypto.getRandomValues(new Uint32Array(length));

  let secret = "";

  for (const index of indexes) {
    secret += charset[index % charset.length];
  }

  return secret;
}
