diff --git a/lib/aws_auth/utils.ex b/lib/aws_auth/utils.ex index bd188ce..0e3acee 100644 --- a/lib/aws_auth/utils.ex +++ b/lib/aws_auth/utils.ex @@ -49,7 +49,11 @@ defmodule AWSAuth.Utils do end def hmac_sha256(key, data) do - :crypto.hmac(:sha256, key, data) + if Code.ensure_loaded?(:crypto) and function_exported?(:crypto, :mac, 4) do + :crypto.mac(:hmac, :sha256, key, data) + else + :crypto.hmac(:sha256, key, data) + end end def bytes_to_string(bytes) do diff --git a/mix.exs b/mix.exs index 68628e0..e4918b9 100644 --- a/mix.exs +++ b/mix.exs @@ -14,7 +14,7 @@ defmodule AWSAuth.Mixfile do end def application do - [applications: [:logger]] + [applications: [:logger, :crypto]] end defp deps do