{"id":19674351,"url":"https://github.com/mirage/digestif","last_synced_at":"2025-04-05T13:05:01.300Z","repository":{"id":30037874,"uuid":"33586940","full_name":"mirage/digestif","owner":"mirage","description":"Simple hash algorithms in OCaml","archived":false,"fork":false,"pushed_at":"2025-01-08T11:36:23.000Z","size":5053,"stargazers_count":89,"open_issues_count":6,"forks_count":27,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-29T12:04:15.442Z","etag":null,"topics":["blake2b","c","hash","md5","ocaml","sha1","sha224","sha256","sha384","sha512"],"latest_commit_sha":null,"homepage":"","language":"OCaml","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/mirage.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2015-04-08T05:35:11.000Z","updated_at":"2025-03-16T20:59:34.000Z","dependencies_parsed_at":"2024-03-18T11:50:22.431Z","dependency_job_id":"6ec634f2-f68e-4996-9235-9f1e30391c55","html_url":"https://github.com/mirage/digestif","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fdigestif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fdigestif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fdigestif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirage%2Fdigestif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirage","download_url":"https://codeload.github.com/mirage/digestif/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247339154,"owners_count":20923014,"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":["blake2b","c","hash","md5","ocaml","sha1","sha224","sha256","sha384","sha512"],"created_at":"2024-11-11T17:18:01.097Z","updated_at":"2025-04-05T13:05:01.266Z","avatar_url":"https://github.com/mirage.png","language":"OCaml","funding_links":[],"categories":["Frameworks and Libs","Security and Cryptography"],"sub_categories":["OCaml"],"readme":"Digestif - Hash algorithms in C and OCaml\n=========================================\n\nDigestif is a toolbox which implements hashes:\n\n * MD5\n * SHA1\n * SHA2\n * SHA3\n * WHIRLPOOL\n * BLAKE2B\n * BLAKE2S\n * RIPEMD160\n\nDigestif uses a trick about linking and let the end-user to choose which\nimplementation he wants to use. We provide 2 implementations:\n\n * C implementation with `digestif.c`\n * OCaml implementation with `digestif.ocaml`\n \nBoth are well-tested. However, OCaml implementation is slower than the C\nimplementation.\n\n**Note**: The linking trick requires `digestif.c` or `digestif.ocaml` to be the\nfirst of your dependencies.\n\nDocumentation: https://mirage.github.io/digestif/\n\nContact: Romain Calascibetta `\u003cromain.calascibet ta@gmail.com\u003e`\n\n## Install \u0026 Usage\n\nThe library is available on [OPAM](https://opam.ocaml.org/packages/digestif/). You can install it via:\n```sh\n$ opam install digestif\n```\n\nThis is a simple program which implements `sha1sum`:\n```sh\n$ cat \u003esha1sum.ml \u003c\u003cEOF\nlet sum ic =\n  let tmp = Bytes.create 0x1000 in\n  let rec go ctx = match input ic tmp 0 0x1000 with\n    | 0 -\u003e Digestif.SHA1.get ctx\n    | len -\u003e\n      let ctx = Digestif.SHA1.feed_bytes ctx ~off:0 ~len tmp in\n      go ctx\n    | exception End_of_file -\u003e Digestif.SHA1.get ctx in\n  go Digestif.SHA1.empty\n\nlet () = match Sys.argv with\n  | [| _; filename; |] when Sys.file_exists filename -\u003e\n    let ic = open_in filename in\n    let hash = sum ic in\n    close_in ic ; print_endline (Digestif.SHA1.to_hex hash)\n  | [| _ |] -\u003e\n    let hash = sum stdin in\n    print_endline (Digestif.SHA1.to_hex hash)\n  | _ -\u003e Format.eprintf \"%s [\u003cfilename\u003e]\\n%!\" Sys.argv.(0)\nEOF\n$ cat \u003edune \u003c\u003cEOF\n(executable\n (name sha1sum)\n (libraries digestif))\nEOF\n$ dune exec ./sha1sum.exe -- sha1sum.ml\nfe6e6639a817c23857b507e2d833ec776f23f327\n```\n\n## API\n\nFor each hash, we implement the same API which is referentially transparent.\nThen, on the top of these, we reflect functions (like `digesti` or `hmaci`) with\nGADT - however, conversion from GADT to hash type is not possible (but you can\n_destruct_ GADT with `to_raw_string`).\n\n## Equal/Compare function\n\nWe deciced to protect users to timing-attack. In this case, `Digestif.equal` (by\n[eqaf](https://github.com/mirage/eqaf.git) package) compares hashes in\nconstant-time.\n\nHowever, we provide `unsafe_compare` function too which is __not__ a constant\ntime function. In some contexts, like `ocaml-git`, we don't care about timing\nattack and we use `unsafe_compare` - then, we need to make a wrap where we\nrename `unsafe_compare` to `compare` to be able to use it in some functors like\n`Map.Make` or `Set.Make`.\n\nIt's little annoying to do that but it forces the user to get the right question\nabout security issues. So, please, don't ask to rename this function.\n\n## MirageOS\n\nOf course, this package is available to be used on MirageOS (both\nimplementations). User is able to compile `digestif.ocaml` with `js_of_ocaml`\nand this package is platform agnostic.\n\n## Build Requirements\n\n * OCaml \u003e= 4.03.0 (may be less but need test)\n * `base-bytes` meta-package\n * `base-bigarray` meta-package\n * `dune` to build the project\n \nIf you want to compile the test program, you need:\n\n * `alcotest`\n\n## Credits\n\nThis work is from the [nocrypto](https://github.com/mirleft/nocrypto) library\nand the Vincent hanquez's work in\n[ocaml-sha](https://github.com/vincenthz/ocaml-sha).\n\nAll credits appear in the begin of files and this library is motivated by two\nreasons:\n  * delete the dependancy with `nocrypto` if you don't use the encryption (and\n    common) part\n  * aggregate all hashes functions in one library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirage%2Fdigestif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirage%2Fdigestif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirage%2Fdigestif/lists"}