I just want to understand what happens to the data when a user submits a login form to a PHP script on server?
Why we hash or encrypt the password on the server side script while the user submits it to the server via a form (I think it's client side script as HTML) in a plain text can be read by any hacker?
-
possible duplicate of Must logins be a https page and Secure hash and salt for PHP passwordsArtjom B.– Artjom B.2015年04月03日 14:35:53 +00:00Commented Apr 3, 2015 at 14:35
-
1"Read by any hacker" is mostly a media exaggeration. Listening to someone's unencrypted internet traffic requires the cracker to connect at some point to your connection to the server, which is often not trivial. Approaches include offering free (malicious) wifi, listening to all traffic on public wifi (both easy), installing a hardware device at someone's office (getting harder), tapping into the public telecommunications network at a roadside routing box (harder still).halfer– halfer2015年04月03日 14:36:48 +00:00Commented Apr 3, 2015 at 14:36
-
Passwords are just one (popular) authentication factor. But there are also others.Gumbo– Gumbo2015年04月03日 14:36:56 +00:00Commented Apr 3, 2015 at 14:36
2 Answers 2
what happens to the data when a user submits a login form to a PHP script on server?
The data travels over the internet from one computer to another. Nothing more, nothing less. What the server does with the submitted data is up to the server.
Why we hash or encrypt the password on the server side...
In order not to store the password in plain text where anybody can see it. A password is a secret that only the user should know and nobody else. Yes, it needs to travel to the server in plain form, this is more or less inevitable. But then the server should do everything in its power to not leave any trace of this plain form around.
...can be read by any hacker.
That's why every data submission should be secured by a SSL/TLS connection. Without that, it's indeed just plaintext on the wire. A properly set up TLS connection in a secure environment is practically unbreakable.
3 Comments
You are right, there can be a MITM (Man In The Middle) attack and the hacker can eventually read your password. That's why the use of HTTPS (everywhere) is preferable to secure your form submission.
Some references that can help you:
1 Comment
Explore related questions
See similar questions with these tags.