commit
be3d418c5a
18
.travis.yml
18
.travis.yml
@ -1,14 +1,18 @@
|
||||
language: erlang
|
||||
|
||||
install: wget https://github.com/erlang/rebar3/releases/download/3.1.0/rebar3 && chmod 755 rebar3
|
||||
|
||||
script: PATH=.:$PATH make update test dialyzer
|
||||
|
||||
notifications:
|
||||
disabled: true
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- 0.1.0
|
||||
|
||||
otp_release:
|
||||
- R15B02
|
||||
- R15B01
|
||||
- R15B
|
||||
- 18.0
|
||||
- 18.1
|
||||
- 18.2
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.cache/rebar3/
|
||||
|
||||
|
41
Makefile
41
Makefile
@ -1,23 +1,30 @@
|
||||
.PHONY: doc
|
||||
REBAR?=rebar3
|
||||
|
||||
.PHONY: \
|
||||
all \
|
||||
clean \
|
||||
nuke \
|
||||
test \
|
||||
update \
|
||||
dialyzer
|
||||
|
||||
all:
|
||||
./rebar compile
|
||||
./rebar doc
|
||||
./rebar xref
|
||||
./rebar eunit
|
||||
|
||||
compile:
|
||||
./rebar compile
|
||||
|
||||
doc:
|
||||
./rebar doc
|
||||
|
||||
xref: compile
|
||||
./rebar xref
|
||||
@$(REBAR) compile
|
||||
|
||||
clean:
|
||||
./rebar clean
|
||||
@$(REBAR) clean
|
||||
|
||||
test: xref
|
||||
./rebar eunit
|
||||
nuke: clean
|
||||
@rm -rf _build
|
||||
|
||||
test:
|
||||
@$(REBAR) eunit
|
||||
|
||||
update:
|
||||
@$(REBAR) update
|
||||
|
||||
dialyzer:
|
||||
@$(REBAR) dialyzer
|
||||
|
||||
coveralls:
|
||||
@${REBAR} coveralls send
|
||||
|
@ -1,8 +1,11 @@
|
||||
{erl_opts, [{i, "src"},
|
||||
warnings_as_errors,
|
||||
debug_info,
|
||||
{w, all},
|
||||
warn_export_all]}.
|
||||
|
||||
{deps, [{hex2bin, "1.0.0"}]}.
|
||||
|
||||
{clean_files, [".eunit",
|
||||
"ebin/*.beam"]}.
|
||||
|
||||
|
@ -1 +1 @@
|
||||
[].
|
||||
[{<<"hex2bin">>,{pkg,<<"hex2bin">>,<<"1.0.0">>},0}].
|
||||
|
@ -5,7 +5,8 @@
|
||||
{registered, []},
|
||||
{applications, [
|
||||
kernel,
|
||||
stdlib
|
||||
stdlib,
|
||||
hex2bin
|
||||
]},
|
||||
{modules, [sha3]},
|
||||
{env, []}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
-export([hash_init/1, hash_update/2, hash_final/1, hash/2]).
|
||||
|
||||
-export([hexhash/2]).
|
||||
|
||||
-on_load(init/0).
|
||||
|
||||
-type bitlen() :: 224 | 256 | 384 | 512.
|
||||
@ -11,6 +13,8 @@
|
||||
|
||||
-type digest() :: <<_:224>> | <<_:256>> | <<_:384>> | <<_:512>>.
|
||||
|
||||
-export_type([bitlen/0, context/0, digest/0]).
|
||||
|
||||
-define(nif_stub, nif_stub_error(?LINE)).
|
||||
nif_stub_error(Line) ->
|
||||
erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).
|
||||
@ -55,3 +59,7 @@ hash_final(_Context) ->
|
||||
hash(_BitLen, _Binary) ->
|
||||
?nif_stub.
|
||||
|
||||
-spec hexhash(bitlen(), binary()) -> binary().
|
||||
hexhash(Bitlen, Binary) ->
|
||||
Hash = hash(Bitlen, Binary),
|
||||
list_to_binary(hex2bin:bin_to_hexstr(Hash)).
|
||||
|
@ -46,3 +46,19 @@ hash_512_test() ->
|
||||
?assertEqual(<<16#94EE7851163C39C3489373AA0BF885D95925EAD7484C586D2E0D01D9C8069D3C30E2EEA2DC63A91B517FE53E43A31D764A2154A2DA92876366B138ABC4406805:512>>,
|
||||
sha3:hash(512, <<16#00112233445566778899AABBCCDDEEFF:128>>)).
|
||||
|
||||
hexhash_224_test() ->
|
||||
?assertEqual(<<"038907E89C919CD8F90A7FBC5A88FF9278108DAEF3EBCDA0CEB383E1">>,
|
||||
sha3:hexhash(224, <<16#00112233445566778899AABBCCDDEEFF:128>>)).
|
||||
|
||||
hexhash_256_test() ->
|
||||
?assertEqual(<<"22BCE46032802AF0ABFACF3768F7BE04A34F5F01DF60F44FFD52D3CA937350C0">>,
|
||||
sha3:hexhash(256, <<16#00112233445566778899AABBCCDDEEFF:128>>)).
|
||||
|
||||
hexhash_384_test() ->
|
||||
?assertEqual(<<"25FAC1ADECBE1B254976FE32C2FE78829B23D7D84316141ECD208D6806A9DB4352A014ADA4106BA0D210DDA0FD18E150">>,
|
||||
sha3:hexhash(384, <<16#00112233445566778899AABBCCDDEEFF:128>>)).
|
||||
|
||||
hexhash_512_test() ->
|
||||
?assertEqual(<<"94EE7851163C39C3489373AA0BF885D95925EAD7484C586D2E0D01D9C8069D3C30E2EEA2DC63A91B517FE53E43A31D764A2154A2DA92876366B138ABC4406805">>,
|
||||
sha3:hexhash(512, <<16#00112233445566778899AABBCCDDEEFF:128>>)).
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user