Uniq provides generation, formatting, parsing, and analysis of RFC 4122 UUIDs, with
support for the draft UUIDv6 extension. It is a package for Elixir projects, and can
be found on Hex as :uniq
.
6ba7b810-9dad-11d1-80b4-00c04fd430c8
, with or without the dashes),
as URNs, e.g. urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8
, as well as a compact, 22-character, base64-encoded format using
a URI-safe alphabet (e.g. a6e4EJ2tEdGAtADAT9QwyA
). 6ba7b810-9dad-11d1-80b4-00c04fd430c8
and 6BA7B810-9DAD-11D1-80B4-00C04FD430C8
have the same encodingUniq.UUID
as the type of a field where you would use Ecto.UUID
. See the docs for more info.elixir_uuid
, see the docs for details on migratingdef deps do
[
{:uniq, "~> 0.1"}
]
end
The primary API is provided by the Uniq.UUID
module.
To generate UUIDs, pick the version you want, and call the appropriate generator. For example:
uuid1/0
, generates UUIDv1 and formats it as a human-readable string, i.e. 6ba7b810-9dad-11d1-80b4-00c04fd430c8
uuid1/1
, generates UUIDv1 in the specified formatuuid3/2
, generates UUIDv3 using the provided namespace and name, and formats it as a human-readable stringuuid3/3
, generates UUIDv3 using the provided namespace and name, in the specified formatSee the docs for the full set of functions available.
You can also convert UUID strings to/from the human-readable and binary formats; parse UUID strings/binaries; and determine their validity.