title: How can I calculate a file checksum in Elixir?
body: <p>I need to calculate the md5 sum of a file in Elixir, how can this be achieved?
  I would expect that something like:</p>
  
  <pre><code>iex(15)&gt; {:ok, f} = File.open "file"
  {:ok, #PID&lt;0.334.0&gt;}
  iex(16)&gt; :crypto.hash(:md5, f)
  ** (ArgumentError) argument error
               :erlang.iolist_to_binary(#PID&lt;0.334.0&gt;)
      (crypto) crypto.erl:225: :crypto.hash/2
  </code></pre>
  
  <p>But clearly it doesn't work..</p>
  
  <p>The documentation of Mix.Utils tells about <a href="https://hexdocs.pm/mix/1.1.1/Mix.Utils.html#read_path/2" rel="nofollow noreferrer">read_path/2</a>, but it didn't worked either.</p>
  
  <pre><code>iex(22)&gt; Mix.Utils.read_path("file", [:sha512])  
  {:ok, "Elixir"} #the expected was {:checksum, "&lt;checksum_value&gt;"}
  </code></pre>
  
  <p>Is there any library that provides such functionality in a easy way?</p>