Compute MD5 digest of file in Haskell -
using haskell, how can compute md5 digest of file without using external tools md5sum?
note: question intentionally shows no effort answered right away.
one option use puremd5 package, example if want compute hash of file foo.txt:
import qualified data.bytestring.lazy lb import data.digest.pure.md5 main :: io () main = filecontent <- lb.readfile "foo.txt" let md5digest = md5 filecontent print md5digest this code prints the same md5 sum md5sum foo.txt.
if prefer one-liner, can use 1 (the imports same above):
lb.readfile "foo.txt" >>= print . md5
Comments
Post a Comment