Extract LastFm.API.Signature

This commit is contained in:
Claudio Ortolina
2025-05-07 08:31:39 +01:00
parent c7491719e3
commit fcdae8f925
2 changed files with 21 additions and 21 deletions
+13
View File
@@ -0,0 +1,13 @@
defmodule LastFm.API.Signature do
def generate(params, shared_secret) do
encoded_params =
params
# Params needs to be ASCII ordered alphabetically
|> Enum.sort()
|> Enum.map_join(fn {key, value} ->
"#{key}#{value}"
end)
:crypto.hash(:md5, encoded_params <> shared_secret) |> Base.encode16(case: :lower)
end
end