Files
music_library/lib/last_fm/api/signature.ex
T
Claudio Ortolina 7cf9b4e7f8 First pass at uniformed types, specs and docs
- spec public functions (skipping controllers, views, live views and
components)
- use types instead of explanations in docs
- remove redundant docs
- fix typos
2026-03-06 08:33:11 +00:00

15 lines
424 B
Elixir

defmodule LastFm.API.Signature do
@spec generate(map() | keyword(), String.t()) :: String.t()
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