What's a canonical way to generate UUIDs in Elixir? Should I necessarily use the library https://hex.pm/packages/uuid or is there a built-in library? I better have less dependencies and do more work than vise versa, therefore if I can generate in Elixir with an external dependency, it'll better go with it.
UUID was standardized by the Open Software Foundation (OSF), becoming a part of the Distributed Computing Environment (DCE). Different versions of UUID follow the RFC 4122 specification. UUIDs are generated using an algorithm based on a timestamp and other factors such as the network address.
A Version 4 UUID is a universally unique identifier that is generated using random numbers. The Version 4 UUIDs produced by this site were generated using a secure random number generator.
(Technically, it's not impossible that the same UUID we generate could be used somewhere else, but with 340,282,366,920,938,463,463,374,607,431,768,211,456 different possible UUIDs out there, the chances are very slim).
Sandwich Attack: A New Way Of Brute Forcing UUIDs Once an attacker knows the web application uses UUID v1 for generating the password reset link, they could take the approach listed below to guess the right token for an arbitrary account: 1.
import Ecto
uuid = Ecto.UUID.generate
If you're using elixir with ecto, you can always use Ecto.UUID https://hexdocs.pm/ecto/Ecto.UUID.html
The canonical way to generate a globally unique reference in Elixir is with make_ref/0
.
From the documentation:
Returns an almost unique reference.
The returned reference will re-occur after approximately 2^82 calls; therefore it is unique enough for practical purposes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With