# \[ANN\] Digestif 0.4

**URL:** <https://discuss.ocaml.org/t/ann-digestif-0-4/1038>\
**Category:** Community\
**Tags:** hash, ripemd, blake2s, sha1, announce\
**Created:** [October 31, 2017, 7:27am UTC](https://discuss.ocaml.org/t/ann-digestif-0-4/1038 "2017-10-31T07:27:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dinosaure](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dinosaure/32/16_2.png) [@dinosaure](https://discuss.ocaml.org/u/dinosaure)\
**Post date:** [October 31, 2017, 7:27am UTC](https://discuss.ocaml.org/t/ann-digestif-0-4/1038/1 "2017-10-31T07:27:25Z")

</div>

Hi all,

I’m happy to announce a new release of [`digestif.0.4`](https://github.com/mirage/digestif/releases/tag/v0.4), available for installation via OPAM.

Digestif is a library which contains some hashes algorithms like:

- MD5
- SHA1
- SHA224
- SHA256
- SHA384
- SHA512
- BLAKE2B

And this new release integrate:

- BLAKE2S
- RIPEMD160

As the previous release, this library provides 2 implementations. One in C and one in OCaml. You need to link your program/library with `digestif.c` to get the first one or `digestif.ocaml` to get the second one (and compile with `js_of_ocaml`).

This release is well-tested on the advise of @cfcs and we did a little benchmark with `core_bench`.

For the C implementation:

```auto
┌────────────────────────────┬──────────┬─────────┬────────────┐
│ Name │ Time/Run │ mWd/Run │ Percentage │
├────────────────────────────┼──────────┼─────────┼────────────┤
│ sha1 (bigstring:1024) │ 5.39us │ 22.00w │ 32.49% │
│ sha1 (bytes:1024) │ 5.46us │ 17.00w │ 32.94% │
│ sha256 (bigstring:1024) │ 8.75us │ 22.00w │ 52.72% │
│ sha256 (bytes:1024) │ 10.39us │ 19.00w │ 62.64% │
│ sha512 (bigstring:1024) │ 7.48us │ 22.00w │ 45.10% │
│ sha512 (bytes:1024) │ 7.11us │ 23.00w │ 42.87% │
│ ripemd160 (bigstring:1024) │ 13.60us │ 22.00w │ 82.00% │
│ ripemd160 (bytes:1024) │ 16.59us │ 17.00w │ 100.00% │
│ blake2b (bigstring:1024) │ 4.59us │ 22.00w │ 27.68% │
│ blake2b (bytes:1024) │ 4.47us │ 23.00w │ 26.93% │
│ blake2s (bigstring:1024) │ 5.51us │ 22.00w │ 33.19% │
│ blake2s (bytes:1024) │ 5.60us │ 19.00w │ 33.75% │
└────────────────────────────┴──────────┴─────────┴────────────┘

```

And the OCaml implementation:

```auto
┌────────────────────────────┬──────────┬─────────┬──────────┬──────────┬────────────┐
│ Name │ Time/Run │ mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │
├────────────────────────────┼──────────┼─────────┼──────────┼──────────┼────────────┤
│ sha1 (bigstring:1024) │ 85.62us │ 17.21kw │ 12.82w │ 12.82w │ 52.31% │
│ sha1 (bytes:1024) │ 86.27us │ 17.16kw │ 12.91w │ 12.91w │ 52.70% │
│ sha256 (bigstring:1024) │ 163.68us │ 29.84kw │ 43.93w │ 43.93w │ 100.00% │
│ sha256 (bytes:1024) │ 138.79us │ 29.80kw │ 45.09w │ 45.09w │ 84.79% │
│ sha512 (bigstring:1024) │ 71.31us │ 19.89kw │ 33.58w │ 33.58w │ 43.57% │
│ sha512 (bytes:1024) │ 72.74us │ 19.86kw │ 31.70w │ 31.70w │ 44.44% │
│ ripemd160 (bigstring:1024) │ 121.48us │ 26.25kw │ 18.14w │ 18.14w │ 74.22% │
│ ripemd160 (bytes:1024) │ 118.38us │ 26.22kw │ 18.55w │ 18.55w │ 72.32% │
│ blake2b (bigstring:1024) │ 77.51us │ 19.72kw │ 20.17w │ 20.17w │ 47.35% │
│ blake2b (bytes:1024) │ 68.31us │ 19.69kw │ 21.23w │ 21.23w │ 41.73% │
│ blake2s (bigstring:1024) │ 145.73us │ 33.06kw │ 34.12w │ 34.12w │ 89.03% │
│ blake2s (bytes:1024) │ 150.63us │ 33.01kw │ 34.48w │ 34.48w │ 92.03% │
└────────────────────────────┴──────────┴─────────┴──────────┴──────────┴────────────┘

```

As my previous announcement, if you want a specific hash algorithm, you can ask to the [issue tracker](https://github.com/mirage/digestif/issues).

---

<div class="post-metadata">

**Author:** ![hannes](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hannes/32/2302_2.png) [@hannes](https://discuss.ocaml.org/u/hannes)\
**Post date:** [October 31, 2017, 9:01am UTC](https://discuss.ocaml.org/t/ann-digestif-0-4/1038/2 "2017-10-31T09:01:34Z")

</div>

This is great, thanks for doing some performance statistics. They would be more informative if you would compare them to other implementations – OpenSSL, (ocaml-)sha, nocrypto and cryptokit come to mind.

---

<div class="post-metadata">

**Author:** ![dinosaure](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dinosaure/32/16_2.png) [@dinosaure](https://discuss.ocaml.org/u/dinosaure)\
**Post date:** [October 31, 2017, 9:05am UTC](https://discuss.ocaml.org/t/ann-digestif-0-4/1038/3 "2017-10-31T09:05:57Z")

</div>

About `nocrypto` and `ocaml-sha`, because `digestif` comes from these implementations (exactly the same code), the result should be the same 🙂 ! However, it could be interesting to compare with `cryptokit` and `openssl` indeed.

---

<div class="post-metadata">

**Author:** ![cfcs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/cfcs/32/833_2.png) [@cfcs](https://discuss.ocaml.org/u/cfcs)\
**Post date:** [October 31, 2017, 12:40pm UTC](https://discuss.ocaml.org/t/ann-digestif-0-4/1038/4 "2017-10-31T12:40:08Z")

</div>

But the functorized memory layout could make a difference - I think it would still be interesting to see what effects that has on performance 🙂
