From 83c47cb7d191e0dfce6a6fe4bd074c2c5db3046d Mon Sep 17 00:00:00 2001 From: Romain Calascibetta Date: Fri, 18 Mar 2022 10:42:51 +0100 Subject: [PATCH] Improve the README.md --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3280280..a77a8b4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ Digestif - Hash algorithms in C and OCaml ========================================= -[![Build Status](https://travis-ci.org/mirage/digestif.svg?branch=master)](https://travis-ci.org/mirage/digestif) - Digestif is a toolbox which implements hashes: * MD5 @@ -23,12 +21,52 @@ implementation he wants to use. We provide 2 implementations: Both are well-tested. However, OCaml implementation is slower than the C implementation. -**Note**: The linking trick requires `digestif.c` or `digestif.ocaml` to be the first of your dependencies. +**Note**: The linking trick requires `digestif.c` or `digestif.ocaml` to be the +first of your dependencies. Documentation: https://mirage.github.io/digestif/ Contact: Romain Calascibetta `` +## Install & Usage + +The library is available on [OPAM][]. You can install it via: +```sh +$ opem install digestif +``` + +This is a simple program which implements `sha1sum`: +```sh +$ cat >sha1sum.ml < Digestif.SHA1.get ctx + | len -> + let ctx = Digestif.SHA1.feed_bytes ctx ~off:0 ~len tmp in + go ctx + | exception End_of_file -> Digestif.SHA1.get ctx in + go Digestif.SHA1.empty + +let () = match Sys.argv with + | [| _; filename; |] when Sys.file_exists filename -> + let ic = open_in filename in + let hash = sum ic in + close_in ic ; print_endline (Digestif.SHA1.to_hex hash) + | [| _ |] -> + let hash = sum stdin in + print_endline (Digestif.SHA1.to_hex hash) + | _ -> Format.eprintf "%s []\n%!" Sys.argv.(0) +EOF +$ cat >dune <