sanichi/elm-md5/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

MD5

This library allows you to compute MD5 message digests in Elm. It exposes a single function that takes any string and outputs a "fingerprint" containing 32 hexadecimal characters. More information about the MD5 algorithm can be found here.

Digest Functions

hex : String -> String

Given a string of arbitrary length, returns a string of 32 hexadecimal characters (a-f, 0-9) representing the 128-bit MD5 message digest.

hex ""          == "d41d8cd98f00b204e9800998ecf8427e"
hex "foobarbaz" == "6df23dc03f9b54cc38a0fc1483df6e21"

Unlike the Javascript program upon which this implementation is based, CRLF pairs in the input are not automatically replaced with LFs prior to computing the digest. If you want that behaviour you should adjust the input yourself before evaluating the function. For example:

myHex : String -> String
myHex input =
    let
        myInput =
            Regex.replace Regex.All (Regex.regex "\x0D\n") (\_ -> "\n") input
    in
        hex myInput