Initial checkin.

This commit is contained in:
Jesper Louis Andersen
2014-11-18 23:16:49 +01:00
commit 9a7f4c8d4e
11 changed files with 178 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
all:
$(MAKE) -C .. compile
+9
View File
@@ -0,0 +1,9 @@
{application, enacl,
[
{description, "Erlang NaCl bindings"},
{vsn, "0.0.1"},
{registered, []},
{applications, [kernel, stdlib]},
{mod, {enacl_app, []}},
{env, []}
]}.
+13
View File
@@ -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().
+10
View File
@@ -0,0 +1,10 @@
-module(enacl_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
enacl_sup:start_link().
stop(_State) ->
ok.
+21
View File
@@ -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}).