Tmp files - what’s wrong with using "phx#{System.unique_integer()"?

Absolutely nothing. :smiley:

Though to remove that last 0.01% chance of collision I’d do it only slightly differently, like so:

  def random_id do
    "phx-"
    |> Kernel.<>(random_encoded_bytes())
    |> String.replace(["/", "+"], "-")
  end

  defp random_encoded_bytes do
    8
    |> :crypto.strong_rand_bytes()
    |> Base.url_encode64()
  end

Or you can use only System.unique_integer but with the :monotonic modifier as well.