I don't know any PHP but here someone already asked how to format a date. If you want ISO8601 as the output it's super easy (Date.utc_today() |> Date.to_iso8601()
).
Elixir does not provide HMAC hashing in its standard library as far as I know. But you can use the Erlang function: :crypto.hash/2
E.g., :crypto.hash(:sha512, "text")
. See the Erlang crypto docs. Note that I'm unsure about what hash_hmac does exactly. If you want a Message Authentication Code, look into the :crypto.mac/3
function.
As for pack("H*", $secretkey)
is that converting an integer to a string in hexadecimal representation? If that's the case, then secret_key |> Integer.to_string(16)
is what you want.
After your comment I assume this is what you want to copy and paste:
hmac_key = "deadbeef"
msg = "your message to sign"
bin_key = hmac_key |> String.to_integer(16)
:crypto.mac(:hmac, :sha512, msg, bin_key) |> Base.encode16()
Obviously you'll still need to substitute msg
and hmac_key
with your values.