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

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
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
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
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
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement