# (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private

**URL:** <https://forum.elixirforum.com/t/undefinedfunctionerror-function-crypto-hmac-3-is-undefined-or-private/40060>\
**Category:** Questions\
**Tags:** phoenix, learning-elixir\
**Created:** [May 28, 2021, 9:37am UTC](https://forum.elixirforum.com/t/undefinedfunctionerror-function-crypto-hmac-3-is-undefined-or-private/40060 "2021-05-28T09:37:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![CafeRacer](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/caferacer/32/22601_2.png) [@CafeRacer](https://forum.elixirforum.com/u/CafeRacer)\
**Post date:** [August 22, 2021, 7:07am UTC](https://forum.elixirforum.com/t/undefinedfunctionerror-function-crypto-hmac-3-is-undefined-or-private/40060/4 "2021-08-22T07:07:00Z")

</div>

**In case you are using a pure Elixir implementation without Plug.**

:crypto.hmac/{3,4} is deprecated and is removed in Erlang/OTP 24.

:crypto.mac/4 should be instead, but it is available only since Erlang/OTP 22.1.

Both functions yield the same result:

```elixir
iex(6)> :crypto.mac(:hmac, :sha256, "key", "data") == :crypto.hmac(:sha256, "key", "data")
true
iex(7)> :crypto.mac(:hmac, :sha384, "key", "data") == :crypto.hmac(:sha384, "key", "data")
true

```

---

_[View the full topic](https://forum.elixirforum.com/t/undefinedfunctionerror-function-crypto-hmac-3-is-undefined-or-private/40060)._
