[erlang-questions] How do you do these operations in Erlang

Magnus Henoch magnus@REDACTED
Thu May 15 13:42:09 CEST 2014

Low Kian Seong <kianseong@REDACTED> writes:

> How do you do the following in idiomatic Erlang:
> "sha1sum <file>" or "md5sum <file>" ?

Read the file with file:read_file/1:

{ok, Data} = file:read_file(".emacs").

And compute the hash with crypto:hash/2:

crypto:hash(md5, Data).

crypto:hash(sha, Data).

See the crypto documentation for more details:


More information about the erlang-questions mailing list