TSFoster/elm-sha1/1.0.5

NOTE: the latest version is 2.1.1

SHA1

Calculate SHA-1 digests in Elm.

This package supports hashing of:

  • String using the utf-8 encoding
  • List Int where the elements are assumed to be below 256

And can represent the digest as:

Documentation

IMPORTANT UPGRADE NOTES

  • elm-sha1 >= v1.0.5 provides large performance improvements, thanks to Folkert de Vries.

  • Upgrade to elm-sha1 >= v1.0.3 for use with elm v0.19.1. An update to the elm compiler to fix a regression will break versions of this package before v1.0.3. Please ensure this package is updated to at least v1.0.3 when upgrading to elm version 0.19.1.

  • There was an issue regarding input data of 311 bytes in versions 1.0.0 and 1.0.1 of this library. If you are using either of these versions, it is highly recommended that you upgrade as soon as possible.

Examples

import SHA1

digest1 : SHA1.Digest
digest1 = SHA1.fromString "string"

digest2 : SHA1.Digest
digest2 = SHA1.fromBytes [0x00, 0xFF, 0xCE, 0x35, 0x74]


SHA1.toHex digest1
--> "ecb252044b5ea0f679ee78ec1a12904739e2904d"

SHA1.toBase64 digest2
--> "gHweOF5Lyg+Ha7ujrlYwNa/Hwgk="

SHA1.toBytes digest1
--> [ 0xEC, 0xB2, 0x52, 0x04, 0x4B
--> , 0x5E, 0xA0, 0xF6, 0x79, 0xEE
--> , 0x78, 0xEC, 0x1A, 0x12, 0x90
--> , 0x47, 0x39, 0xE2, 0x90, 0x4D
--> ]

Validation

Not officially validated through CAVP/CMVP.

This package is also tested against additional hashes in the documentation (using elm-verify-examples), tests/Tests.elm, and indirectly via romariolopezc/elm-hmac-sha1’s tests, and TSFoster/elm-uuid’s tests.

Please note that SHA-1 is not “considered secure against well-funded opponents”, but it does have its uses, including, but not limited to, version 5 UUIDs.

Contributors

Special thanks to Folkert de Vries for a major rewrite of this library, including huge performance gains, more rigorous testing, and support for elm/bytes.

Other contributors:

TODO

  • Benchmarks
    • Add way to run benchmarks
    • Automate testing that changes do not negatively impact performance?
  • Write CONTRIBUTING.md