I decided to implement the user login using the salt for each user stored in the database. The salt has a password prefix that is hashed with the SHA and stored in the database.
In the past, when I didnβt use salt, I would use a typical method of counting the number of rows returned by a query using the user name and password entered by the user. Along with the user's salt, you need to get the salt before you can compare it with the saved password hash.
So, in order to avoid two requests (1 to get the salt, and the other to check the input credentials), I decided to get the salt AND the hashed password in one request based on the username entered. Sort of
SELECT users.salt, users.password FROM users WHERE username = ?'
and then in the serveride code (PHP) file, I concatenate the salt with the entered password, hash it and compare it with the password already taken from the database.
If this is not clear, I think the key difference is that in the last method, I check the credentials in PHP before it is done in the database.
Are there any security flaws in this method or otherwise
zenna source share