description
SHA is a cryptographic hash function. SHA1 implements the second implementation that produce a 160 bit digest from a message. SHA256 implements newer version that produce 256 bits digest. SHA512 implement 512 bits digest
This provide a interface for OCaml program to use SHA1, SHA256 and SHA512 functions.
Sha modules are now available through debian packaging system, courtesy of Eric Cooper. just install the package libsha-ocaml-dev using your favorite dpkg tools (apt-get, aptitute, ...).
download
Thoses package contains multiple SHA implementation:
Thoses versions contains only SHA1:
- version 1.0
- version 0.9
- version 0.8
- version 0.7
- version 0.6
- version 0.5
- version 0.4
- version 0.3
- version 0.2
- version 0.1
documentation
The interface is similar of the MD5 Digest available in OCaml standard library here.
You can turn a digest into a printable string through Sha1.to_hex
- Sha1.string : string -> t
- Sha1.substring : string -> int -> int -> t
- Sha1.channel : in_channel -> int -> t
- Sha1.file : string -> t
- Sha1.input : in_channel -> t
- Sha1.output : out_channel -> t -> unit
- Sha1.to_hex : t -> string
The Sha256 and Sha512 interface are absolutely the same (with Sha256/512 instead of Sha1 ;))
Changelog
- 1.5: 2 Makefiles fixes (Florent Monnier)
- 1.4: Reduce code duplication by using a functor
- 1.3: implement SHA512.
- 1.2: lots of optimisations for SHA1.
- 1.1: implement SHA256.
- 1.0: Lot of performance tweaking. Misc fixes.
- 0.9: Tweak sha1 algorithm to be faster, using linux kernel SHA1 code with some unrolling inspiration from GNU coreutils. sha1sum become only 2 slower than coreutils sha1sum. more tweak to come.
- 0.8: Finish implement sha1sum (add check mode), now almost equivalent of the C sha1sum
- 0.7: Improve performance using an imperative algorithm for channel and switch to -O2 for C part.
- 0.6: Add small sha1sum program equivalent to C sha1sum for single use.
- 0.5: Hide low level function, update now take an offset argument. add high level function, similar to ones available in MD5 Digest.
- 0.4: Rename some stubs function, and few type renaming.
- 0.3: Use direct caml heap to store the sha1_ctx object instead of mallocing it.
- 0.2: Cleanup, fix memory leak, add unit testing, build native and bytecode libraries.
- 0.1: initial implementation.