Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rlopzc/elm-hmac-sha1
Compute HMAC with SHA-1 hash function
https://github.com/rlopzc/elm-hmac-sha1
elm hmac-sha1
Last synced: 2 months ago
JSON representation
Compute HMAC with SHA-1 hash function
- Host: GitHub
- URL: https://github.com/rlopzc/elm-hmac-sha1
- Owner: rlopzc
- License: mit
- Created: 2018-12-20T03:15:25.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-15T14:26:56.000Z (over 2 years ago)
- Last Synced: 2023-08-08T20:39:57.829Z (over 1 year ago)
- Topics: elm, hmac-sha1
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/rlopzc/elm-hmac-sha1/latest/
- Size: 18.6 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://package.elm-lang.org/packages/elm/bytes/latest/)).
This is important as you can represent the data as you want.More information of HMAC [here](https://en.wikipedia.org/wiki/HMAC).
## Examples
Some API's use the HMAC SHA-1 as Authentication, like Amazon or Twitter.
```elm
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](https://github.com/TSFoster/elm-sha1) 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](https://github.com/ktonon/elm-crypto) 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):```bash
cd elm-hmac-sha1
elm-verify-examples --fail-on-warn && elm-test
```[elm-verify-examples]: https://github.com/stoeffel/elm-verify-examples