-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Salt not extracted from hash when performing check #35
Comments
Hi @zakhdar, your test works fine on my machine (Ubuntu 18.04, Java 11.0.10+9) so it has to be analyzed. Can you please re-do your test but with It may be that your machine does not support a strong secure random source or, if it is supported, something in the library is not working as expected on your environment. |
Dear @firaja , You will find bellow the results of various tests requested.
With global.random.strong=true Result :
With global.random.strong=false Result :
thank you for your support. |
@zakhdar thanks for the info. This is probably due to a not specified encoding in The extracted salt in Please, can you send me the result of the following piece of code? System.out.println(Charset.defaultCharset().name()); If it is not UTF-8 then we have almost certainly found the issue. |
You got it right, indeed the charset on my machine is windows-1252 hence the problem, if I add as an argument to the JVM -Dfile.encoding = UTF-8 the library works correctly.
It might be interresting to provide an addition in the documentation or possibly raise an exception in the program if the encoding of the machine is different from that used by the library , or maybe the librairy can use charset of the machine by default. Thank you for your help and your work !! |
this commit solves the issue: the encoding must be the same along with the library and be consistent across different environments. Thank you for your time 😉 |
Released in 1.5.3. |
Great job!!! Thank you so much!!! I just ran into this problem these days when local project works fine (JVM's default encoding is |
Describe the bug
in the documentation (for Argon2) it is mentioned that the SALT is stored in the computed hash and therefore automatically used during a call to check, which is not the case and needs to be specified again manually during a verification call.
When the documentation refers to the hash, does it refer to the com.password4j.Hash object ? or the computed hash (hash.getResult()) ? it maybe not a bug but the documentation is unclear on this point.
To Reproduce
psw4j.properties :
Test :
Working code :
Expected behavior
If salt is already embedded in the computed hash (hash.getResult()) it need to automatically extracted from here (if it exists) in the verification function , this would avoid having in database (result has saved in db in my case) a column for the result and another column which would contain the salt.
Environment:
java version "11.0.9" 2020-10-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)
The text was updated successfully, but these errors were encountered: