ariandanim

ariandanim

Bcypt not functional in Windows 11

I am using Windows 11, with Elixir 1.17.3 and Erlang 27.1, tried make encryption auth using bcrypt but still not working, here the code error below when trying create new account :

[debug] HANDLE EVENT "save" in EventflowWeb.UserRegistrationLive
  Parameters: %{"_csrf_token" => "NgA1axEPDzodO1goMgsAMBohGQ4pBBsAEK_1GICryH7FpJLREraOftH9", "user" => %{"email" => "test@gmail.com", "password" => "[FILTERED]"}}
[debug] QUERY OK source="users" db=0.1ms queue=0.1ms idle=1803.9ms
SELECT 1 FROM "users" AS u0 WHERE (u0."email" = ?) LIMIT 1 ["test@gmail.com"]
↳ Ecto.Changeset.unsafe_validate_unique/4, at: lib/ecto/changeset.ex:2700
[error] Process #PID<0.828.0> raised an exception
** (RuntimeError) An error occurred when loading Bcrypt.
Make sure you have a C compiler and Erlang 20 installed.
If you are not using Erlang 20, either upgrade to Erlang 20 or
use version 0.12 of bcrypt_elixir.
See the Comeonin wiki for more information.

    (bcrypt_elixir 3.2.0) lib/bcrypt/base.ex:15: Bcrypt.Base.init/0
    (kernel 10.1) code_server.erl:1356: anonymous fn/1 in :code_server.handle_on_load/5
[warning] The on_load function for module Elixir.Bcrypt.Base returned:
{%RuntimeError{
   message: "An error occurred when loading Bcrypt.\nMake sure you have a C compiler and Erlang 20 installed.\nIf you are not using Erlang 20, either upgrade to Erlang 20 or\nuse version 0.12 of bcrypt_elixir.\nSee the Comeonin wiki for more information.\n"
 },
 [
   {Bcrypt.Base, :init, 0,
    [file: ~c"lib/bcrypt/base.ex", line: 15, error_info: %{...}]},
   {:code_server, :"-handle_on_load/5-fun-0-", 1,
    [file: ~c"code_server.erl", line: 1356]}
 ]}

[error] GenServer #PID<0.630.0> terminating
** (UndefinedFunctionError) function Bcrypt.Base.gen_salt/2 is undefined (module Bcrypt.Base is not available)
    (bcrypt_elixir 3.2.0) Bcrypt.Base.gen_salt(12, false)
    (bcrypt_elixir 3.2.0) lib/bcrypt.ex:77: Bcrypt.hash_pwd_salt/2
    (eventflow 0.1.0) lib/eventflow/users/user.ex:76: Eventflow.Users.User.maybe_hash_password/2
    (eventflow 0.1.0) lib/eventflow/users.ex:79: Eventflow.Users.register_user/1
    (eventflow 0.1.0) lib/eventflow_web/live/user_registration_live.ex:57: EventflowWeb.UserRegistrationLive.handle_event/3
    (phoenix_live_view 1.0.0-rc.6) lib/phoenix_live_view/channel.ex:508: anonymous fn/3 in Phoenix.LiveView.Channel.view_handle_event/3
    (telemetry 1.2.1) c:/Users/Ariandani/app/phoenix/eventflow/deps/telemetry/src/telemetry.erl:321: :telemetry.span/3
    (phoenix_live_view 1.0.0-rc.6) lib/phoenix_live_view/channel.ex:260: Phoenix.LiveView.Channel.handle_info/2
    (stdlib 6.1) gen_server.erl:2345: :gen_server.try_handle_info/3
    (stdlib 6.1) gen_server.erl:2433: :gen_server.handle_msg/6
    (stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: %Phoenix.Socket.Message{topic: "lv:phx-F__O4w2TMQDsaRDD", event: "event", payload: %{"event" => "save", "type" => "form", "value" => "_csrf_token=NgA1axEPDzodO1goMgsAMBohGQ4pBBsAEK_1GICryH7FpJLREraOftH9&user%5Bemail%5D=test%40gmail.com&user%5Bpassword%5D=testgmail123"}, ref: "33", join_ref: "16"}
State: %{socket: #Phoenix.LiveView.Socket<id: "phx-F__O4w2TMQDsaRDD", endpoint: EventflowWeb.Endpoint, view: EventflowWeb.UserRegistrationLive, parent_pid: nil, root_pid: #PID<0.630.0>, router: EventflowWeb.Router, assigns: %{form: nil, __changed__: %{}, current_user: nil, flash: %{}, live_action: :new, trigger_submit: false, check_errors: false}, transport_pid: #PID<0.623.0>, ...>, components: {%{}, %{}, 1}, topic: "lv:phx-F__O4w2TMQDsaRDD", serializer: Phoenix.Socket.V2.JSONSerializer, join_ref: "16", upload_names: %{}, upload_pids: %{}}
[debug] MOUNT EventflowWeb.UserRegistrationLive
  Parameters: %{}
  Session: %{"_csrf_token" => "sKjZVFLHdsonBALb_SxAOpS9"}
[debug] Replied in 1ms
[debug] HANDLE EVENT "validate" in EventflowWeb.UserRegistrationLive
  Parameters: %{"_csrf_token" => "NgA1axEPDzodO1goMgsAMBohGQ4pBBsAEK_1GICryH7FpJLREraOftH9", "_target" => ["user", "email"], "user" => %{"_unused_email" => "", "_unused_password" => "[FILTERED]", "email" => "test@gmail.com", "password" => "[FILTERED]"}}
[debug] Replied in 204µs

I am also install all c++ compiler in visual studio tools completed (almost GB file)

here some source code i forked :

Marked As Solved

NobbZ

NobbZ

The comeonin README already warns windows users that they will have problems using bcrypt and argon2 and suggest to use pbkdf2 which has no NIF dependencies.

Also Liked

mikejm

mikejm

If you are just developing on Windows but that is not your deployment target, you can run Ubuntu from Windows very easily using “WSL”

See

That is how I operate these days. Too many packages for Elixir won’t work on Windows.

mitkins

mitkins

I’ve compiled bcrypt on Windows before - but the process is not fun. Once bcrypt is compiled, you’ll forget all about it - until you upgrade or move to a new PC. Then you’ll have to do it all over again!

On a Windows machine, if you create a new Phoenix project and then run:

mix phx.gen.auth

It will use pbkdf2 instead of bcrypt. In the generated code the pdkdf2 calls are identical to their bcrypt counterparts (same function names/signatures).

StepSanch

StepSanch

I’m facing the same issue on my Windows 11 environment. Before compiling Bcrypt on Windows, you need to configure your development environment.

To do this, in the same shell where you’ll be compiling, run the following command: cmd /K “C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat” -arch=x64. This command sets up your shell. The path needs to be customized to reflect your specific installation.

You should also consider removing the previous version of Bcrypt in your _build/dev/lib (if it wasn’t compiled correctly) or force the compilation with the command ‘mix deps.compile bcrypt_elixir --force’.

mitkins

mitkins

There’s mention of the three libraries here:

https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Auth.html#module-password-hashing

Which also refers to the README on Comonin. Further digging reveals:

The long and the short of it is - consider using Argon2 (which requires more memory) and that bcrypt and pdkdf2 are comparable (but more susceptable to GPU attacks)

Where Next?

Popular in Questions Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement