mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
11 lines
302 B
Elixir
11 lines
302 B
Elixir
|
defmodule Philomena.Sha512 do
|
||
|
@spec file(String.t()) :: String.t()
|
||
|
def file(file) do
|
||
|
hash_ref = :crypto.hash_init(:sha512)
|
||
|
|
||
|
File.stream!(file, [], 10_485_760)
|
||
|
|> Enum.reduce(hash_ref, &:crypto.hash_update(&2, &1))
|
||
|
|> :crypto.hash_final()
|
||
|
|> Base.encode16(case: :lower)
|
||
|
end
|
||
|
end
|