Initial checkin.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
$(MAKE) -C .. compile
|
||||
@@ -0,0 +1,9 @@
|
||||
{application, enacl,
|
||||
[
|
||||
{description, "Erlang NaCl bindings"},
|
||||
{vsn, "0.0.1"},
|
||||
{registered, []},
|
||||
{applications, [kernel, stdlib]},
|
||||
{mod, {enacl_app, []}},
|
||||
{env, []}
|
||||
]}.
|
||||
@@ -0,0 +1,13 @@
|
||||
-module(enacl).
|
||||
|
||||
-export([
|
||||
hash/1,
|
||||
box_keypair/0
|
||||
]).
|
||||
|
||||
hash(Bin) ->
|
||||
enacl_nif:crypto_hash(Bin).
|
||||
|
||||
box_keypair() ->
|
||||
enacl_nif:crypto_box_keypair().
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
-module(enacl_app).
|
||||
-behaviour(application).
|
||||
|
||||
-export([start/2, stop/1]).
|
||||
|
||||
start(_StartType, _StartArgs) ->
|
||||
enacl_sup:start_link().
|
||||
|
||||
stop(_State) ->
|
||||
ok.
|
||||
@@ -0,0 +1,21 @@
|
||||
-module(enacl_nif).
|
||||
|
||||
-export([
|
||||
crypto_hash/1,
|
||||
crypto_box_keypair/0
|
||||
]).
|
||||
-on_load(init/0).
|
||||
|
||||
init() ->
|
||||
SoName = filename:join(
|
||||
case code:priv_dir(enacl) of
|
||||
{error, bad_name} ->
|
||||
filename:join(filename:dirname(filename:dirname(code:which(?MODULE))), "priv");
|
||||
Dir ->
|
||||
Dir
|
||||
end, atom_to_list(?MODULE)),
|
||||
erlang:load_nif(SoName, 0).
|
||||
|
||||
crypto_hash(Input) when is_binary(Input) -> error({nif_not_loaded, ?MODULE}).
|
||||
crypto_box_keypair() -> error({nif_not_loaded, ?MODULE}).
|
||||
|
||||
Reference in New Issue
Block a user