I need to make a log-in system and having basically no previous knowledge of how it's done (with security in mind) I studied it on the internet. The way I would do it now is something like this:
- Server has login information in a database table - username and a password hash per user (encrypted with SHA224 for example).
- When client wants to authenticate, password is encrypted with SHA224 (client-side) and sent with username to the server to verify a match in the database.
- If the user ticked "Remember me" option, an authentication key is generated on the server, inserted into a database along with the IP of the client.
- The authentication key is sent to the client and stored in cookies.
- Now, when the client returns, authentication key from cookies is sent to the server, the server finds it in the database and checks if the IPs match as well. If it does, the user is authenticated and a new authentication key is generated and sent to the user (and stored in cookies) for next visit.
My questions are:
- How does encrypting password make this any safer? The hash still can be captured on the way from client to server and misused just as well as if it was plaintext. I know that this is an elementary question but I somehow couldn't find an answer to this one.
- Is this security system secure enough? (or better yet - Did I get it right?)