Can we use Scrypt for password hash in phoenix?

I want to use Scrypt for password hashing and couldn’t find any working library. If anyone has used it before and can guide me how can I use it in phoenix?

There seem to be a couple Erlang implementations you could use. I never used them, so I cannot recommend one, but a search for “scrypt erlang” gives me at least these two:

  • erlang-scrypt - Erlang port driver for Colin Percival’s “scrypt” function
  • erl-scrypt - Erlang NIF wrapper for Colin Percival’s scrypt library

The second one also has an Elixir usage example in the README.

1 Like

second one I used it but it did not work. Let me try first
one

For second one I’m getting this error

** (CompileError) mix.exs:55: undefined function scrypt/0
    (elixir 1.10.2) src/elixir_locals.erl:114: anonymous fn/3 in :elixir_locals.ensure_no_undefined_local/3
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6

What is on line 55 of your mix.exs?

I’ve added the dep. Which is mentioned in first link provided above

What exactly is line 55 of your mix.exs?

This
{scrypt, “1.1.6:0”, “git://github.com/tonyg/erlang-scrypt.git”, “master”}}

As the first element of the tuple, it needs to be :scrypt, i.e. an atom. Now it’s treated as a function that cannot be found.

Yes but the dependency is in wrong format too. Am I right?

Probably… That looks like a rebar git dependency…

{:scrypt, github: "tonyg/erlang-scrypt"} might work, though could be a rebar 2 project, based on the age… Its {:scrypt, github: "tonyg/erlang-scrypt", manager: :rebar}.

It might not be compatible with modern erlang.

Yes. It’s okay I have found the suitable library

You will get issue in this. I have resolved it according to my need.

Hey there! May I ask what issues you had? I am the library maintainer :slight_smile:

I went ahead and officially published the package with some added documentation: https://hex.pm/packages/scrypt_elixir

2 Likes