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:
               sha1()
               | sha2()
               | sha3()
               | :ripemd160
               | compatibility_only_hash(),
             data: iodata(),
             digest: binary()

md5 is part of the compatibility_only_hash()
http://erlang.org/doc/man/crypto.html#type-hash_algorithm

3 Likes

… 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.
Source: Erlang -- crypto

2 Likes