smarkets / erlang-bcrypt Goto Github PK
View Code? Open in Web Editor NEWThis project forked from abhay/erlang-bcrypt
Erlang wrapper for OpenBSD's Blowfish password hashing code
License: Other
This project forked from abhay/erlang-bcrypt
Erlang wrapper for OpenBSD's Blowfish password hashing code
License: Other
18> bcrypt:hashpw([1], element(2, bcrypt:gen_salt())).
{ok,"$2a$12$rrb1UvG99VjksrmA3o8.6uN0jx2tWXXsKTlHkL6N5sqyg1mv.6/OK"}
19> bcrypt:hashpw([0], element(2, bcrypt:gen_salt())).
=ERROR REPORT==== 8-Aug-2011::12:20:15 ===
Port died: 139
=ERROR REPORT==== 8-Aug-2011::12:20:15 ===
** Generic server <0.70.0> terminating
** Last message in was {#Port<0.1084>,{exit_status,139}}
** When Server state == {state,#Port<0.1084>,12}
** Reason for termination ==
** port_died
** exception exit: {port_died,{gen_server,call,
[<0.70.0>,
{hashpw,[0],"$2a$12$wVVtLRy2GnObV9ND3q2pRe"},
infinity]}}
in function gen_server:call/3
20> bcrypt:mechanism().
port
This is only tested on ports, no idea if NIFs handle it well or just crash. Anybody could submit such data, especially if you're sending JSON data structures around:
{'user': 'bob', 'pass':'abc\u0000d'}
Wish should be decoded to "abc\0d"
and give the same crash.
If no support for special characters of this kind are given, then at least returning an error (without a crash) or telling people to base64 encode it before using the library should be part of the manuals/readme, I guess.
I am getting this error when compiling the nif
Applications/Xcode.app/Contents/Developer/usr/bin/make -f c_src/Makefile.erlang.mk
cc -c -o c_src/async_queue.o c_src/async_queue.c -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/bcrypt.o c_src/bcrypt.c -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/bcrypt_nif.o c_src/bcrypt_nif.c -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/bcrypt_port.o c_src/bcrypt_port.c -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -c -o c_src/blowfish.o c_src/blowfish.c -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include -Ic_src -Wall -fPIC -finline-functions -Wall -fPIC -I /usr/local/Cellar/erlang/18.1/lib/erlang/erts-7.1/include -I /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/include
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
clang: warning: argument unused during compilation: '-finline-functions'
cc -o priv/bcrypt_nif.so c_src/async_queue.o c_src/bcrypt.o c_src/bcrypt_nif.o c_src/bcrypt_port.o c_src/blowfish.o -flat_namespace -undefined suppress -L /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/lib -lerl_interface -lei -bundle -flat_namespace -undefined suppress -L /usr/local/Cellar/erlang/18.1/lib/erlang/lib/erl_interface-3.8/lib -lerl_interface -lei -lpthread -shared
clang: error: invalid argument '-bundle' not allowed with '-dynamiclib'
make[2]: *** [priv/bcrypt_nif.so] Error 1
make[1]: *** [pre-app] Error 2
Hi!
56> bcrypt:hashpw("12456", "$2b$12$j4P7eTvx7x2F.wj6HORIzetQmoegqZ1xo0B2jo/XNABgN5lMWswMi").
{error,"bcrypt failed"}
The hash string
is produced by comeonin
Env: Erlang/OTP 20+
Exec following code
> {ok, Salt} = bcrypt:gen_salt().
exception error:
** exception exit: {{function_clause,[{bcrypt_nif_worker,terminate,
[{undef,[{crypto,rand_bytes,[16],[]},
{bcrypt_nif,gen_salt,1,
[{file,"src/bcrypt_nif.erl"},{line,57}]},
...
If bcrypt is added as a dependency in a "rebar3 project" then the port executable priv/bcrypt
is not built. The .so
file is built.
Am wondering what needs to be changed to the rebar.config file to enable building the executable (which is needed for the port mechanism).
The bcrypt_nif.so is missing.
/rel/tengiStore/lib/bcrypt-0.4.1/priv/bcrypt_nif.so: cannot open shared object file: No such file or directory'"
The library fails to compile on SmartOS the issue is -lnsl
is missing when linking.
#include <sys/types.h>
This line is needed to compile on Alpine Linux (musl). Could we get at least this change in master?
Any idea why u_*
types are in play here (vs. say uint8_t
)? They look non-standard to me.
bcrypt.app.src vsn still lists 0.4.0 under 0.4.1 tag. rebar very unhappy, please fix.
https://github.com/smarkets/erlang-bcrypt/blob/0.4.1/src/bcrypt.app.src
Thanks.
In my Ubuntu virtual machine (Intel(R) Xeon(R) CPU E5-2430 0 @ 2.20GHz 16 cores, 64G memory), bcrypt:hashpw runs for more than 1 second. Is this normal? I worry that this is not fast enough for production use when registered users are more than half million.
8> {ok, Salt} = bcrypt:gen_salt().
{ok,"$2a$12$BWhbfsZTZI50EVRmsc2/q."}
9> {ok, Hash} = bcrypt:hashpw("foo", Salt). (more than 1 second)
{ok,"$2a$12$BWhbfsZTZI50EVRmsc2/q.emrJQ6J9Av4semi4/X4x11USlhypCIq"}
10> {ok, Hash} =:= bcrypt:hashpw("foo", Hash). (more than 1 second)
true
My env:
Ubuntu 14.04.3 LTS
Kernel: 3.13.0-74-generic x86_64
Erlang:
Package: esl-erlang
Priority: extra
Section: interpreters
Installed-Size: 124643
Maintainer: Erlang Solutions Ltd [email protected]
Architecture: amd64
Source: esl-erlang
Version: 1:18.2
I starts erlang by "erl -pa ebin -boot start_sasl -s crypto -s bcrypt".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.