For MD5:
:crypto.hash(:md5, :erlang.term_to_binary(%{k1: "val1", k2: "val2"}))
=> <<225, 87, 188, 155, 209, 54, 124, 25, 115, 196, 104, 11, 221, 200, 140, 247>>
You can use Base to encode it into a string, if needed:
:crypto.hash(:md5, :erlang.term_to_binary(map)) |> Base.encode64
=> "4Ve8m9E2fBlzxGgL3ciM9w=="
:crypto.hash(:md5, :erlang.term_to_binary(map)) |> Base.encode16
=> "E157BC9BD1367C1973C4680BDDC88CF7
:crypto.hash/2 also works with :sha, :sha256, :blake2b, etc.
Above both maps are same as order doesn't matter in map. How to create a hash from map so that their hash are same too ?
It's worth pointing out that maps are unordered in Elixir/Erlang, so the two maps in your example produce the same map internally - the order of the keys in the source code is irrelevant:
%{k1: "val1", k2: "val2"} == %{k2: "val2", k1: "val1"}
=> true