defmodule Algora.Util do
  @common_words [
    "a",
    "add",
    "again",
    "air",
    "also",
    "an",
    "and",
    "are",
    "as",
    "ask",
    "at",
    "be",
    "but",
    "by",
    "can",
    "do",
    "does",
    "each",
    "end",
    "even",
    "for",
    "from",
    "get",
    "got",
    "had",
    "have",
    "he",
    "here",
    "his",
    "how",
    "i",
    "if",
    "in",
    "is",
    "it",
    "kind",
    "men",
    "must",
    "my",
    "near",
    "need",
    "of",
    "off",
    "on",
    "one",
    "or",
    "other",
    "our",
    "out",
    "put",
    "said",
    "self",
    "set",
    "some",
    "such",
    "tell",
    "that",
    "the",
    "their",
    "they",
    "this",
    "to",
    "try",
    "us",
    "use",
    "want",
    "was",
    "we're",
    "we",
    "well",
    "went",
    "were",
    "what",
    "which",
    "why",
    "will",
    "with",
    "you're",
    "you",
    "your"
  ]

  def common_word?(s), do: Enum.member?(@common_words, s)

  def random_string do
    binary = <<
      System.system_time(:nanosecond)::64,
      :erlang.phash2({node(), self()})::16,
      :erlang.unique_integer()::16
    >>

    binary
    |> Base.url_encode64()
    |> String.replace(["/", "+"], "-")
  end
end