Created
December 6, 2017 15:34
-
-
Save jiahaog/c5a280f9effe9a6136d1f54a5aa0e4cd to your computer and use it in GitHub Desktop.
MD5 Hex Representation in Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build-depends: base >= 4.7 && < 5 | |
, base16-bytestring | |
, bytestring | |
, cryptohash-md5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...