Closed jisaacks closed 6 years ago
The value for the salt is generated randomly when you call "create" as a part of the initialisation:
https://github.com/technion/ruby-argon2/blob/master/lib/argon2.rb#L17
It is intended that you get different results for every hash you create (even with the same input), as this is how the salt prevents rainbow attacks.
This is consistent with the operation of bcrypt, and you can read more about this pattern here: https://stackoverflow.com/questions/39197989/laravel-5-using-bcrypt-on-same-string-gives-different-values
If would only be a bug if those inputs failed to verify, which is checked in the tests here: https://github.com/technion/ruby-argon2/blob/master/test/rubycheck_test.rb
In your second example, you've reused the hash object, which reuses the salt. This is probably a bad idea, and I'll add some documentation to this effect.
Thanks so much! That clarified everything.
When just using
Argon2::Password.create
I am starting to get different results every time (I have been using this code for over a year tho and it has not been an issue until now).however if I create an instance like this it works:
Could this be something environmental that is causing it to always be different? Is this a bug?
Happy to give any other info you may need.