Trying to understand documentation

Hi all, i have a few beginner questions

  1. am i right to say that :crypto is a library from erlang and not elixir?
  2. :crypto.hash(:md5, input) this works but in the documentation show below :md5 is not one of the type mentioned. So what happening? Is the doc wrong?
iex(3)> h :crypto.hash/2
* :crypto.hash/2

  @spec hash(type, data) :: digest
        when type:
               | sha2()
               | sha3()
               | :ripemd160
               | compatibility_only_hash(),
             data: iodata(),
             digest: binary()

md5 is part of the compatibility_only_hash()


… and yes, it’s from Erlang, as You can guess from the atom name :slight_smile:

1 Like

It’s part of Erlang core - similarly to how String is in Elixir core.

You need to take a look at crypto documentation:

compatibility_only_hash() = md5 | md4

The compatibility_only_hash() algorithms are recommended only for compatibility with existing applications.