For a login system in php would this be a suitable outline of how it would work:
users types in username and password, clicks login button.
- Checks if user exists in database,
- if it does, then retrieve the salt
for that user - hash the password and
salt (would this be done on the
client or server side? I think
client side would be better, but php
is server side so how would you do
this?) - check value against value in
database, - if the values match then
user has typed in correct password
and they are logged in.
No. This means you are hitting your database twice.
No. The point of hashing the password is so that if someone compromises your database, they can’t (easily) find out what they need to send to your system (or other systems) to log in as that user.
If you hash the password before sending it to the server, then the attacker can bypass the JS and send the prehashed password read from the database to your system.