From e20d5d08c4d3ec935f7abf7a74c339da44db2837 Mon Sep 17 00:00:00 2001 From: SUZUKI Tetsuya Date: Wed, 3 Oct 2012 17:33:04 +0900 Subject: [PATCH] write edoc --- src/sha3.erl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sha3.erl b/src/sha3.erl index 1b15118..25f16a8 100644 --- a/src/sha3.erl +++ b/src/sha3.erl @@ -5,7 +5,10 @@ -on_load(init/0). -type bitlen() :: 224 | 256 | 384 | 512. + -type context() :: binary(). +%% State of hash operation return. + -type digest() :: <<_:224>> | <<_:256>> | <<_:384>> | <<_:512>>. -define(nif_stub, nif_stub_error(?LINE)). @@ -23,18 +26,31 @@ init() -> end, erlang:load_nif(filename:join(PrivDir, sha3_nif), 0). +%% @doc Returns a new context for hash operation. +%% Bit length of digest (`BitLen') must be one of 224, 256, 384 and 512. +%% @see hash_update/2 -spec hash_init(bitlen()) -> context(). hash_init(_BitLen) -> ?nif_stub. +%% @doc Updates the digest by `Context' generated with `hash_init/1' +%% using the given `Data' and returns a new updated context. +%% `Data' can be any length. +%% The returned context can e used `hash_update/2' or `hash_final/1'. +%% @see hash_final/1 -spec hash_update(context(), binary()) -> context(). hash_update(_Context, _Binary) -> ?nif_stub. +%% @doc Finalizes the hash operation with `Context' and +%% returns a message digest. +%% Length of the digest is determined by an argument of `hash_init/1'. -spec hash_final(context()) -> digest(). hash_final(_Context) -> ?nif_stub. +%% @doc Computes a message digest from `Binary'. +%% Bit length of digest (`BitLen') must be one of 224, 256, 384 and 512. -spec hash(bitlen(), binary()) -> digest(). hash(_BitLen, _Binary) -> ?nif_stub.