zyro / elixir-uuid

UUID generator and utilities for Elixir
Apache License 2.0
361 stars 83 forks source link

Crypto warning when compiling #60

Open pdgonzalez872 opened 2 years ago

pdgonzalez872 commented 2 years ago

Hi! Thanks for the lib!

I'm getting this when compiling:

==> elixir_uuid
Compiling 1 file (.ex)
warning: :crypto.hash/2 defined in application :crypto is used by the current application but the current application does not depend on :crypto. To fix this, you must do one of:

  1. If :crypto is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs

  2. If :crypto is a dependency, make sure it is listed under "def deps" in your mix.exs

  3. In case you don't want to add a requirement to :crypto, you may optionally skip this warning by adding [xref: [exclude: [:crypto]]] to your "def project" in mix.exs

Found at 2 locations:
  lib/uuid.ex:589: UUID.namebased_uuid/2
  lib/uuid.ex:593: UUID.namebased_uuid/2

warning: :crypto.strong_rand_bytes/1 defined in application :crypto is used by the current application but the current application does not depend on :crypto. To fix this, you must do one of:

  1. If :crypto is part of Erlang/Elixir, you must include it under :extra_applications inside "def application" in your mix.exs

  2. If :crypto is a dependency, make sure it is listed under "def deps" in your mix.exs

  3. In case you don't want to add a requirement to :crypto, you may optionally skip this warning by adding [xref: [exclude: [:crypto]]] to your "def project" in mix.exs

Found at 3 locations:
  lib/uuid.ex:383: UUID.uuid4/1
  lib/uuid.ex:560: UUID.uuid1_clockseq/0
  lib/uuid.ex:583: UUID.uuid1_node/1

Generated elixir_uuid app

Here are my versions:

Erlang/OTP 24 [erts-12.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Interactive Elixir (1.12.0) - press Ctrl+C to exit (type h() ENTER for help)

but I also tested this on 1.11-OTP 22 and we get the same warning.

Would you welcome a PR that fixed the warning? I'll create one, feel free to merge if you'd like!

Thanks for the library!

Hentioe commented 2 years ago

This library has not been maintained for a long time, and no PRs have been merged. I recommend you to use the Erlang library https://github.com/okeuday/uuid.

Create a uuid like this:

iex> :uuid.get_v4() |> :uuid.uuid_to_string() |> List.to_string()
"17c2237c-144b-41bc-a872-a9d135678209"
louiscb commented 2 years ago

For future users who want to start using the Erlang library I wanted to add a couple comments:

The following executes much faster than the built in :uuid string conversion as mentioned above.

  :uuid.get_v4() |> Ecto.UUID.load()

If you're using uuid v3 and want backwards compatibility with elixir-uuid and the Erlang UUID then you need to use this method:

 :uuid.get_v3_compat(<<0::128, data::binary>>)