Skip to content

Latest commit

 

History

History
252 lines (150 loc) · 8.7 KB

readme.rst

File metadata and controls

252 lines (150 loc) · 8.7 KB

Sha2SML

Sha2SML (which is abbreviated for [SHA2 - StandardML]) is a SHA2 algorithm implementation of StandardML. SHA2 is defined in rfc6234.

Feature

This library provides below 4 kinds of hash algorithms defined as SHA2:

  • SHA224
  • SHA256
  • SHA384
  • SHA512

Environment

This library had been developped with SML/NJ 110.82, but recent versions should be work well.

Install

SML/NJ

To install Sha2SML to your environment, run the install target of Makefile.smlnj.

$ make -f Makefile.smlnj install

Or you can specify install directory with PREFIX like below

$ make -f Makefile.smlnj install PREFIX=~/.sml/smlnj

The install target requires SMLDoc to generates documentations. To install library without documentations, use install-nodoc target.

$ make -f Makefile.smlnj install-nodoc

To complete the installation, add an entry to the PATHCONFIG file.

$ echo "libsha2sml .sml/smlnj/lib/libsha2sml" >> ~/.smlnj-pathconfig

Once the above steps are completed, Sha2SML can be used from anywhere in your environment:

$ sml
> CM.make "$/libsha2sml.cm";
(* ... snip ... *)
[New bindings added.]
val it = true : bool

Load to Interactive Environment

Sha2SML allows users to loading it in place:

$ sml
- CM.make "libsha2sml.cm";
(* ... snip ... *)
val it = true : bool
- Sha256.hashString "";
val it = - : ?.Sha256.word Sha256.t
- Sha256.toString it;
val it = "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855"
  : string

MLton

To install Sha2SML for MLton, run the install target of Makefile.mlton.

$ make -f Makefile.mlton install

Or you can specify install directory with PREFIX like below

$ make -f Makefile.mlton install PREFIX=~/.sml/mlton

The install target requires SMLDoc to generates documentations. To install library without documentations, specify install-nodoc target.

$ make -f Makefile.mlton install-nodoc

To complete the installation, add an entry to the mlb-path-map file as follows.

$ PREFIX=... # default /usr/local/mlton
$ make install PREFIX=${PREFIX}
$ echo "SHA2SML ${PREFIX}/lib/libsha2sml" >> /path/to/mlb-path-map

Poly/ML

To build this library for Poly/ML, run the target libsha2sml of Makefile.polyml.

$ make -f Makefile.polyml install

Or you can specify install directory with PREFIX like below

$ make -f Makefile.polyml install PREFIX=~/.sml/polyml

The install target requires SMLDoc to generates documentations. To install library without documentations, specify install-nodoc target.

$ make -f Makefile.polyml install-nodoc

Load to Interactive Environment

Sha2SML allows users to loading it in place:

$ poly
- PolyML.loadModule "./libsha2sml.poly";
(* ... snip ... *)
val it = (): unit
- Sha256.hashString "";
val it = - : ?.Sha256.word Sha256.t
- Sha256.toString it;
val it = "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855":
  string

Doc

To generates documentations of Sha2SML, run the doc target.

$ make -f Makefile.(smlnj|mlton|polyml) doc

Test

This project containts a unit test module provides many test cases. These test cases are imported from:

Note

Not all cases are executed as unit test.

SML/NJ

To run the unit tests, run the test target.

$ make -f Makefile.smlnj test
(* ... snip ... *)
Heap was already up-to-date.
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
tests = 951, failures = 0, errors = 0
Failures:
Errors:

MLton

To run the unit tests, run the test target.

$ make -f Makefile.mlton test


$ ./test/sources
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
tests = 951, failures = 0, errors = 0
Failures:
Errors:

Poly/ML

Building and executing the unit test project with Make.

$ export POLYML_LIBDIR=/path/to/lib
$ make -f Makefile.polyml test
Making test
Making Sha2Test
..
polyc -o sha2test-poly sha2test-poly.o
./sha2test-poly
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
tests = 951, failures = 0, errors = 0
Failures:
Errors: