json_web_token_ex icon indicating copy to clipboard operation
json_web_token_ex copied to clipboard

function :crypto.hmac/3 is undefined or private

Open mcfiredrill opened this issue 4 years ago • 4 comments

I think the newer version of crypto.hmac has 4 arguments instead of 3 (OTP 20 and above?).

** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private
    (crypto 5.0) :crypto.hmac(:sha256, "xxxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxx")
    lib/json_web_token/algorithm/hmac.ex:35: JsonWebToken.Algorithm.Hmac.verify?/4
    lib/json_web_token/jws.ex:103: JsonWebToken.Jws.verified/3
    lib/json_web_token/jwt.ex:89: JsonWebToken.Jwt.verify/2

mcfiredrill avatar Jul 29 '21 22:07 mcfiredrill

I'm getting the same error, but :crypto:mac/4 is recommended:

** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private, use crypto:mac/4 instead

Sgoettschkes avatar Sep 06 '21 07:09 Sgoettschkes

Who has managed to resolve this.

alvinotienokelly avatar Oct 18 '22 12:10 alvinotienokelly

Stumbled upon the same problem. Too bad this is the first library mentioned at jwt.io for Elixir and it is not maintained nor working.

I ended up using Erlang's JWErl library. Pretty easy to use also from Elixir, is still maintained and works as promised. There's some lack of documentation if need to use some options, but it's possible to get this information from tests.

jarmo avatar Mar 12 '23 20:03 jarmo