ViperCoderJay

ViperCoderJay

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

I’m failing to render any page, the application takes giving me the following error

[error] #PID<0.1204.0> running ElixirWeb.Endpoint (connection #PID<0.1203.0>, stream id 1) terminated
Server: localhost:8080 (http)
Request: GET /
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private
        (crypto 5.0) :crypto.hmac/3
        (plug_crypto 1.2.0) lib/plug/crypto/key_generator.ex:81: Plug.Crypto.KeyGenerator.generate/7
        (plug_crypto 1.2.0) lib/plug/crypto/key_generator.ex:67: Plug.Crypto.KeyGenerator.with_cache/3
        (plug_crypto 1.2.0) lib/plug/crypto/key_generator.ex:51: Plug.Crypto.KeyGenerator.generate/6
        (plug 1.11.0) lib/plug/session/cookie.ex:114: Plug.Session.COOKIE.put/4
        (plug 1.11.0) lib/plug/session.ex:94: anonymous fn/3 in Plug.Session.before_send/2
        (elixir 1.12.0) lib/enum.ex:2356: Enum."-reduce/3-lists^foldl/2-0-"/3
        (plug 1.11.0) lib/plug/conn.ex:1691: Plug.Conn.run_before_send/2
        (plug 1.11.0) lib/plug/conn.ex:407: Plug.Conn.send_resp/1
        (phoenix 1.5.6) lib/phoenix/endpoint/render_errors.ex:78: Phoenix.Endpoint.RenderErrors.instrument_render_and_send/5
        (phoenix 1.5.6) lib/phoenix/endpoint/render_errors.ex:64: Phoenix.Endpoint.RenderErrors.__catch__/5
        (phoenix 1.5.6) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.8.0) ~/elixir/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.8.0) ~/elixir/deps/cowboy/src/cowboy_stream_h.erl:300: :cowboy_stream_h.execute/3
        (cowboy 2.8.0) ~/elixir/deps/cowboy/src/cowboy_stream_h.erl:291: :cowboy_stream_h.request_process/3
        (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

Marked As Solved

fuelen

fuelen

Try to update plug_crypto library. It uses :crypto.hmac/3 which was removed in OTP 24.
As you can see on GitHub, newer version of plug_crypto supports OTP 24 plug_crypto/key_generator.ex at 6ba8fd42a68351459fe6c769ca04aea6022a5cd1 · elixir-plug/plug_crypto · GitHub

17
Post #2

Also Liked

CafeRacer

CafeRacer

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:

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
manhtranlinh

manhtranlinh

By this error I have just know now mix there are more interesting options :smiley:
Example: mix deps.update --all

kip

kip

ex_cldr Core Team

:crypto.hmac/3 is not available in OTP 24 (it was deprecated in OTP 23). This is being called from mongodb - which therefore needs updating. And it looks like this commit on September 28th does exactly that.

Since that code appears unreleased you might be able to adjust your mix.exs to be:

def deps do
  ...
  {:mongodb, github: "elixir-mongo/mongodb"},
  ...
end
Mkaith

Mkaith

updated this dependency but still facing the same issue.
Pls help

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New

We're in Beta

About us Mission Statement