Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
1. removed hard coded priv path 2. added a simple test
  • Loading branch information
mrinalwadhwa committed Apr 29, 2010
1 parent 199d33c commit b2a02869ba2839d1b491bf2d7f9dc2a8fb6f7129
Showing 3 changed files with 21 additions and 2 deletions.
@@ -2,6 +2,9 @@ all: compile

compile:
@ ./rebar compile

tests:
@ ./rebar eunit

clean:
@ ./rebar clean
@@ -33,11 +33,17 @@

%%--------------------------------------------------------------------
%% @doc Load the bcrypt NIFs
%% @spec start() -> ok
%% @spec init() -> ok
%% @end
%%--------------------------------------------------------------------
init() ->
erlang:load_nif("priv/bcrypt_drv", 0).
NIF = filename:join([
filename:dirname(code:which(?MODULE)),
"..",
"priv",
?MODULE
]) ++ "_drv",
erlang:load_nif(NIF, 0).

%%--------------------------------------------------------------------
%% @doc Generate a salt with the default number of rounds, 12.
@@ -0,0 +1,10 @@
-module(bcrypt_tests).
-include_lib("eunit/include/eunit.hrl").

simple_test_() ->
{timeout, 1000, %% since bcrypt can take long, this is to avoid eunit timeout
fun() ->
Hash = bcrypt:hashpw("foo", bcrypt:gen_salt()),
?assert(Hash =:= bcrypt:hashpw("foo", Hash)),
?assertNot(Hash =:= bcrypt:hashpw("bar", Hash))
end}.

0 comments on commit b2a0286

Please sign in to comment.