romariolopezc/elm-hmac-sha1/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.

Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/rlopzc/elm-hmac-sha1 exists but has no tag 3.0.1; Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 3.0.1 found (4 same-name repos checked); no cached copy. Use another version.

Details

HmacSha1

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

type Digest

An HMAC-SHA1 digest.

fromString : Key -> String -> Digest

Pass a Key and your message as a String to compute a Digest

import HmacSha1.Key as Key


"The quick brown fox jumps over the lazy dog"
    |> fromString (Key.fromString "key")
    |> toHex
--> "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"


"The quick brown fox jumps over the lazy dog"
    |> fromString (Key.fromString "key")
    |> toBase64
--> "3nybhbi3iqa8ino29wqQcBydtNk="
fromBytes : Key -> Bytes -> Digest

Pass a Key and your message in Bytes to compute a Digest

import HmacSha1.Key as Key
import Bytes.Encode


Bytes.Encode.sequence []
    |> Bytes.Encode.encode
    |> fromBytes (Key.fromString "")
    |> toBase64
--> "+9sdGxiqbAgyS31ktx+3Y3BpDh0="

Representation

toBytes : Digest -> 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.

import Bytes
import HmacSha1.Key as Key


fromString (Key.fromString "key") "message"
    |> toBytes
    |> Bytes.width
--> 20
toByteValues : Digest -> List Int

Convert a Digest into a List of Integers. Each Integer is in the range 0-255, and represents one byte. Can be useful for passing digest on to other packages that make use of this convention.

import HmacSha1.Key as Key


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

Convert a Digest into a base16 String

import HmacSha1.Key as Key


fromString (Key.fromString "key") "message"
    |> toHex
--> "2088df74d5f2146b48146caf4965377e9d0be3a4"
toBase64 : Digest -> String

Convert a Digest into a base64 String

import HmacSha1.Key as Key


fromString (Key.fromString "key") "message"
    |> toBase64
--> "IIjfdNXyFGtIFGyvSWU3fp0L46Q="