Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. def md5_digest_for_file_at_path(file_path) do
  2. File.stream!(file_path, [:read, :binary], 1024 * 1024)
  3. |> Stream.chunk(1)
  4. |> Enum.reduce(
  5. :crypto.hash_init(:md5),
  6. fn(chunk, acc) ->
  7. :crypto.hash_update(acc, hd(chunk))
  8. end)
  9. |> :crypto.hash_final
  10. |> Base.encode16
  11. |> String.downcase
  12. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement