Skip to content

Instantly share code, notes, and snippets.

@jiahaog
Created December 6, 2017 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiahaog/c5a280f9effe9a6136d1f54a5aa0e4cd to your computer and use it in GitHub Desktop.
Save jiahaog/c5a280f9effe9a6136d1f54a5aa0e4cd to your computer and use it in GitHub Desktop.
MD5 Hex Representation in Haskell
build-depends: base >= 4.7 && < 5
, base16-bytestring
, bytestring
, cryptohash-md5
import qualified Crypto.Hash.MD5 as MD5
import Data.ByteString.Base16 (encode)
import Data.ByteString.Char8 (pack, unpack)
-- |The 'hash' takes a string and returns the hexadecimal representation of its MD5 checksum
hash :: String -> String
hash = unpack . encode . MD5.hash . pack
@jiahaog
Copy link
Author

jiahaog commented Dec 6, 2017

I was working on Advent of Code 2017 and accidentally switched the URL to 2016 Day 5 where I spent some time setting up this utility function before I spotted my mistake...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment