Add hexhash/2
This commit is contained in:
+2
-1
@@ -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)).
|
||||
|
||||
Reference in New Issue
Block a user