Where do I salt and hash my Passwords? At the client or at the host?

前端 未结 3 1944
死守一世寂寞
死守一世寂寞 2021-01-06 11:12

I think it would be smarter to salt and hash passwords directly on the client\'s machine. The reason is, that I actually never want to get the password of the user. It is a

3条回答
  •  离开以前
    2021-01-06 12:03

    The trouble with that is that the salted, hashed password then travels over the network, and if anyone intercepts it, they can use it.

    What might work is if the server sends the salt to be used to the client, and the client then sends back the salted, hashed password using the server-created salt. The attacker might be able to capture the reply, but it won't help since the server's salt will be different each time, so the response from the client will be different each time. However, that requires the server to know the password so that it can rehash it with the salt, defeating one of your goals.

    Fundamentally, the server has to end up knowing something to ensure that the client isn't spoofing it; and the classic way to do that is to have the server store the salted, hashed password and the client sends the password to the server, which validates what the client sends by salting and hashing the sent password and comparing the result with what it has stored. This avoids the server keeping the password in clear text, but does mean that the password travels over the wire. Make sure that the password is encrypted before being sent, therefore.

提交回复
热议问题