Name: digestif
Owner: MirageOS
Description: Simple hash algorithms in OCaml
Created: 2015-04-08 05:35:11.0
Updated: 2018-02-27 21:48:24.0
Pushed: 2018-03-21 17:22:23.0
Size: 260
Language: OCaml
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Digestif (and Rakia) provid some hashes functions in OCaml. Rakia provides theses functions by a C stub and Digestif is a pure implementation in OCaml of theses hashes. So these hashes functions can be used in an OCaml/Mirage/JavasScript world.
Obviously, Rakia is more faster than Digestif (the hot loop was implemented in C) but it's possible than Rakia can't compile in your architecture. In this case, it's better to use Digestif or send a PR to fix Rakia.
Home page: http://din.osau.re/
Documentation: http://mirage.github.io/digestif/api.docdir/
Contact: Romain Calascibetta <romain.calascibet ta@gmail.com>
We provide an interface with no dependancy (only with Bigarray
, available by
the OCaml distribution). You can choose between the Bytes
module or the
Bigstring
module. You can't remove the dependancy with Bigarray
because the
context of the hash function is internally a Bigarray.Array1.t
.
We provide the same interface:
t
ctx
buffer
init : unit -> ctx
feed : ctx -> buffer -> unit
get : ctx -> t
digest : buffer -> t
digestv : buffer list -> t
hmac : key:buffer -> buffer -> t
hmacv : key:buffer -> buffer list -> t
compare : t -> t -> int
eq : t -> t -> bool
neq : t -> t -> bool
pp : Format.formatter -> t -> unit
of_hex : buffer -> t
to_hex : t -> buffer
buffer
can be a Bytes.t
or a Bigstring.t
. We have an imperative and a
functionnal way to produce a hash. t
is not equivalent between the module
Bytes
and the module Bigstring
.
At this time, we implemented these hashes:
If you want an other hash function, you can ask in the issue.
base-bytes
meta-packagetopkg
, ocamlbuild
and ocamlfind
to build the projectIf you want to compile the test program, you need:
alcotest
This work is from the nocrypto library and the Vincent hanquez's work in ocaml-sha.
All credits appear in the begin of files and this library is motivated by two reasons:
nocrypto
if you don't use the encryption (and common) partWe deleted the cstruct
hard dependancy (from nocrypto
) and provide a
interface to compute with the Bytes.t
. We add the blake2b
implementation too
and we have the plan to provide the hash function in pure OCaml and other hashes
functions. Finally, you can use nocrypto
and digestif
together (no clash
name in the C stub, don't worry).
So, yes, it's redundant but deal with it!