Erlang's builtin md5 function gives out a binary type, while I needed a hexademical string. I found a solution somewhere in the internet, but it was buggy. Note that case statement. This is to fix the bug in the original solution (sorry, dont remember the link). Here is the snippet:
md5_hexdigest(String) ->
string:to_lower(
lists:flatten(
lists:map(
fun(V) ->
case httpd_util:integer_to_hexlist(V) of
[A, B] -> [A, B];
[B] -> [$0, B]
end
end,
binary_to_list(erlang:md5(String))
))).
Комментариев нет:
Отправить комментарий