Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule HashData do
- def open_file do
- File.read! "rand.txt"
- end
- def hash_contents(n) do
- open_file()
- |> hash_contents(n)
- end
- def hash_contents(hash, n) when n < 1 do
- hash
- |> Base.encode16
- |> String.downcase
- end
- def hash_contents(hash, n) do
- :crypto.hash(:sha256, hash)
- |> hash_contents(n - 1)
- end
- end
- defmodule Benchmark do
- def measure(function) do
- function
- |> :timer.tc
- |> elem(0)
- |> Kernel./(1_000_000)
- end
- end
Add Comment
Please, Sign In to add comment