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

elm-hmac-sha1

Compute HMAC message digests using SHA-1 hash function. You provide a key and a message and you get a digest. You can convert the digest into different representations like Bytes, Base16 or Base64.

This provide the native Bytes (elm/bytes). This is important as you can represent the data as you want.

More information of HMAC here.

IMPORTANT: Incorrect calculation in older versions

Please note that there was an issue regarding input data in versions 2.0.0 and previous of this library. If you are using either of these versions, it is highly recommended that you upgrade as soon as possible.

Examples

Some API's use the HMAC SHA-1 as Authentication, like Amazon or Twitter.

import HmacSha1
import HmacSha1.Key as Key exposing (Key)

canonicalString : String
canonicalString =
    String.join ","
        [ "application/json"
        , ""
        , "/account"
        , "Wed, 02 Nov 2016 17:26:52 GMT"
        ]

appKey : Key
appKey =
    Key.fromString "verify-secret"

HmacSha1.fromString appKey canonicalString
    |> HmacSha1.toBase64
--> "nLet/JEZG9CRXHScwaQ/na4vsKQ="

Notes

This package doesn't implement the SHA-1 hash function. It internally uses this implementation.

HMAC strength depends on the hashing algorithm and SHA-1 is not considered cryptographically strong. Use this package to interoperate with systems that already uses HMAC SHA-1 and not for implementing new systems.

There are stronger cryptographic algorithms like HMAC SHA-2, and this Elm package implements it.

Testing

This package uses doc tests, which can be tested using elm-verify-examples. To run all tests (assuming elm-test and elm-verify-examples are installed):

cd elm-hmac-sha1
elm-verify-examples --fail-on-warn && elm-test