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 :
https://github.com/rizafahmi/eventflow

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.

https://github.com/riverrun/comeonin#windows-users

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

https://documentation.ubuntu.com/wsl/en/latest/guides/install-ubuntu-wsl2/

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’.

Last Post!

mitkins

mitkins

There’s mention of the three libraries here:

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

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
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 44265 214
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement