riverrun / argon2_elixir

Elixir wrapper for the Argon2 password hashing algorithm
Apache License 2.0
229 stars 34 forks source link

Base.verify_nif does not works #33

Closed marinakr closed 5 years ago

marinakr commented 5 years ago

I create hash with

hash = Argon2.Base.hash_password("1", "salt-01111111111", [t_cost: 1, argon2_type: 2])

I am trying to verify hash:

Argon2.Base.verify_nif(hash, "1", 2)

and it fails:

** (ArgumentError) argument error
    (argon2_elixir) Argon2.Base.verify_nif("$argon2id$v=19$m=131072,t=1,p=4$c2FsdC0wMTExMTExMTExMQ$i+GCPGDQxyS2zinYa9skuKUrVt2vvSDYMJgzodxww1Y", "1", 2)

Am I miss something?

riverrun commented 5 years ago

Before running Argon2.Base.verify_nif, you need to convert the hash to list, by using :binary.bin_to_list - see the implementation of verify_pass for an example.