romariolopezc/elm-hmac-sha1/1.0.0

NOTE: the latest version is 3.0.1

Renamed to rlopzc/elm-hmac-sha1. It is published under that name, and new versions come out there.

Versions published as romariolopezc/elm-hmac-sha1 still install under that name. 6 versions of 7 come from the new location (see their notes). 1 version could not be recovered and cannot be installed.

Rerouted (fork, verified). The original repository is gone. This copy comes from a fork that still has the tag. The Lamdera package server serves a copy recovered from https://github.com/Malax/elm-hmac-sha1 (a fork).

What we checked: Rebuilt with git archive from commit e8a811ab3c75 of https://github.com/Malax/elm-hmac-sha1 (a fork) (zip prefix romariolopezc-elm-hmac-sha1-d2ebd89/, America/Los_Angeles times, the tag object d2ebd897f0de it had before it was re-made, tagger time 2018-12-24 02:57 UTC): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 ec3af4ae629ca35bfa1541367b94decf2f3a58b6.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/romariolopezc/elm-hmac-sha1/zipball/1.0.0/

HmacSha1

Computes a Hash-based Message Authentication Code (HMAC) using the SHA-1 hash function

type Digest

A HMAC-SHA1 digest.

digest : String -> String -> Digest

Pass a Key and a Message to compute a Digest

digest "key" "The quick brown fox jumps over the lazy dog"
    |> toHex
--> Ok "DE7C9B85B8B78AA6BC8A7A36F70A90701C9DB4D9"


digest "key" "The quick brown fox jumps over the lazy dog"
    |> toBase64
--> Ok "3nybhbi3iqa8ino29wqQcBydtNk="

Representation

toBytes : Digest -> Result String Bytes

Convert a Digest into elm/bytes Bytes. You can use this to map it to your own representations. I use it to convert it to Base16 and Base64 string representations.

toBytes (digest "key" "message")
--> Ok (<80 bytes>)
toIntList : Digest -> Result String (List Int)

Convert a Digest into a List of Integers. Sometimes you will want to have the Byte representation as a list of integers.

toIntList (digest "key" "message")
    |> toIntList
--> Ok [32,136,223,116,213,242,20,107,72,20,108,175,73,101,55,126,157,11,227,164]
toHex : Digest -> Result String String

Convert a Digest into a base16 String Result

case toHex (digest "key" "message") of
    Ok base16String ->
        "Hex string: " ++ base16String


    Err err ->
        "Failed to convert the digest"


--> Hex string: 2088DF74D5F2146B48146CAF4965377E9D0BE3A4
toBase64 : Digest -> Result String String

Convert a Digest into a base64 String Result

case toBase64 (digest "key" "message") of
    Ok base64String ->
        "Base64 string: " ++ base64String


    Err err ->
        "Failed to convert the digest"


--> Base64 string: IIjfdNXyFGtIFGyvSWU3fp0L46Q=