{"id":26933543,"url":"https://github.com/ppad-tech/sha512","last_synced_at":"2025-06-23T13:33:51.816Z","repository":{"id":261559235,"uuid":"884223553","full_name":"ppad-tech/sha512","owner":"ppad-tech","description":"Pure Haskell SHA-512, HMAC-SHA512","archived":false,"fork":false,"pushed_at":"2025-03-01T04:23:03.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T09:19:30.039Z","etag":null,"topics":["cryptography","hashing","haskell","sha2","sha512"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ppad-tech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-06T11:22:13.000Z","updated_at":"2025-03-01T08:44:39.000Z","dependencies_parsed_at":"2025-01-19T15:35:17.601Z","dependency_job_id":"7d6f39a0-fcb5-4b45-a577-1ae36b4fecb5","html_url":"https://github.com/ppad-tech/sha512","commit_stats":null,"previous_names":["ppad-tech/sha512"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ppad-tech/sha512","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fsha512","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fsha512/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fsha512/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fsha512/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppad-tech","download_url":"https://codeload.github.com/ppad-tech/sha512/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppad-tech%2Fsha512/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261487178,"owners_count":23166033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","hashing","haskell","sha2","sha512"],"created_at":"2025-04-02T09:19:32.284Z","updated_at":"2025-06-23T13:33:46.801Z","avatar_url":"https://github.com/ppad-tech.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sha512\n\n[![](https://img.shields.io/hackage/v/ppad-sha512?color=blue)](https://hackage.haskell.org/package/ppad-sha512)\n![](https://img.shields.io/badge/license-MIT-brightgreen)\n[![](https://img.shields.io/badge/haddock-sha512-lightblue)](https://docs.ppad.tech/sha512)\n\nA pure Haskell implementation of SHA-512 and HMAC-SHA512 on strict and\nlazy ByteStrings, as specified by RFC's [6234][r6234] and [2104][r2104].\n\n## Usage\n\nA sample GHCi session:\n\n```\n  \u003e :set -XOverloadedStrings\n  \u003e\n  \u003e -- import qualified\n  \u003e import qualified Crypto.Hash.SHA512 as SHA512\n  \u003e\n  \u003e -- 'hash' and 'hmac' operate on strict bytestrings\n  \u003e\n  \u003e let hash_s = SHA512.hash \"strict bytestring input\"\n  \u003e let hmac_s = SHA512.hmac \"strict secret\" \"strict bytestring input\"\n  \u003e\n  \u003e -- 'hash_lazy' and 'hmac_lazy' operate on lazy bytestrings\n  \u003e -- but note that the key for HMAC is always strict\n  \u003e\n  \u003e let hash_l = SHA512.hash_lazy \"lazy bytestring input\"\n  \u003e let hmac_l = SHA512.hmac_lazy \"strict secret\" \"lazy bytestring input\"\n  \u003e\n  \u003e -- results are always unformatted 512-bit (64-byte) strict bytestrings\n  \u003e\n  \u003e import qualified Data.ByteString as BS\n  \u003e\n  \u003e BS.take 10 hash_s\n  \"\\189D*\\v\\166\\245N\\216\\\u00261\\243\"\n  \u003e BS.take 10 hmac_l\n  \"#}9\\185\\179\\233[\u0026\\246\\205\"\n  \u003e\n  \u003e -- you can use third-party libraries for rendering if needed\n  \u003e -- e.g., using base64-bytestring:\n  \u003e\n  \u003e import qualified Data.ByteString.Base64 as B64\n  \u003e\n  \u003e B64.encode (BS.take 16 hash_s)\n  \"vUQqC6b1Ttgx8+ydx4MmtQ==\"\n  \u003e B64.encode (BS.take 16 hmac_l)\n  \"I305ubPpWyb2zUi4pwDkrw==\"\n```\n\n## Documentation\n\nHaddocks (API documentation, etc.) are hosted at\n[docs.ppad.tech/sha512][hadoc].\n\n## Performance\n\nThe aim is best-in-class performance for pure, highly-auditable Haskell\ncode.\n\nCurrent benchmark figures on my mid-2020 MacBook Air look like (use\n`cabal bench` to run the benchmark suite):\n\n```\n  benchmarking ppad-sha512/SHA512 (32B input)/hash\n  time                 1.116 μs   (1.103 μs .. 1.130 μs)\n                       0.999 R²   (0.999 R² .. 0.999 R²)\n  mean                 1.142 μs   (1.132 μs .. 1.154 μs)\n  std dev              37.35 ns   (30.15 ns .. 49.36 ns)\n  variance introduced by outliers: 45% (moderately inflated)\n\n  benchmarking ppad-sha512/HMAC-SHA512 (32B input)/hmac\n  time                 4.943 μs   (4.823 μs .. 5.086 μs)\n                       0.997 R²   (0.994 R² .. 1.000 R²)\n  mean                 4.878 μs   (4.838 μs .. 4.946 μs)\n  std dev              180.9 ns   (105.1 ns .. 337.4 ns)\n  variance introduced by outliers: 48% (moderately inflated)\n```\n\nCompare this to Hackage's famous SHA package:\n\n```\n  benchmarking ppad-sha512/SHA512 (32B input)/SHA.sha512\n  time                 2.371 μs   (2.350 μs .. 2.401 μs)\n                       0.999 R²   (0.999 R² .. 1.000 R²)\n  mean                 2.422 μs   (2.403 μs .. 2.443 μs)\n  std dev              69.84 ns   (51.04 ns .. 114.0 ns)\n  variance introduced by outliers: 37% (moderately inflated)\n\n  benchmarking ppad-sha512/HMAC-SHA512 (32B input)/SHA.hmacSha512\n  time                 8.832 μs   (8.714 μs .. 8.976 μs)\n                       0.999 R²   (0.998 R² .. 1.000 R²)\n  mean                 8.911 μs   (8.834 μs .. 9.006 μs)\n  std dev              278.9 ns   (215.8 ns .. 365.1 ns)\n  variance introduced by outliers: 37% (moderately inflated)\n```\n\nOr the relevant SHA-512-based functions from a library with similar\naims, [noble-hashes][noble] (though with no HMAC-SHA512 benchmark\navailable):\n\n```\nSHA512 32B x 217,296 ops/sec @ 4μs/op ± 2.00% (min: 3μs, max: 20ms)\n```\n\n## Security\n\nThis library aims at the maximum security achievable in a\ngarbage-collected language under an optimizing compiler such as GHC, in\nwhich strict constant-timeness can be challenging to achieve.\n\nThe HMAC-SHA512 functions within pass all [Wycheproof vectors][wyche],\nas well as various other useful unit test vectors found around the\ninternet.\n\nIf you discover any vulnerabilities, please disclose them via\nsecurity@ppad.tech.\n\n## Development\n\nYou'll require [Nix][nixos] with [flake][flake] support enabled. Enter a\ndevelopment shell with:\n\n```\n$ nix develop\n```\n\nThen do e.g.:\n\n```\n$ cabal repl ppad-sha512\n```\n\nto get a REPL for the main library.\n\n## Attribution\n\nThis implementation has benefitted immensely from the [SHA][hacka]\npackage available on Hackage, which was used as a reference during\ndevelopment. Many parts wound up being direct translations.\n\n[nixos]: https://nixos.org/\n[flake]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html\n[hadoc]: https://docs.ppad.tech/sha512\n[hacka]: https://hackage.haskell.org/package/SHA\n[r6234]: https://datatracker.ietf.org/doc/html/rfc6234\n[r2104]: https://datatracker.ietf.org/doc/html/rfc2104\n[noble]: https://github.com/paulmillr/noble-hashes\n[wyche]: https://github.com/C2SP/wycheproof\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppad-tech%2Fsha512","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppad-tech%2Fsha512","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppad-tech%2Fsha512/lists"}