defmodule A2AEx.ID do @moduledoc false @doc """ Generate a new random UUID v4 string. """ @spec new() :: String.t() def new do <> = :crypto.strong_rand_bytes(16) <> |> uuid_to_string() end defp uuid_to_string(<>) do hex(a, 8) <> "-" <> hex(b, 4) <> "-" <> hex(c, 4) <> "-" <> hex(d, 4) <> "-" <> hex(e, 12) end defp hex(int, pad) do int |> Integer.to_string(16) |> String.downcase() |> String.pad_leading(pad, "0") end end