What is the purpose of the “salt” when hashing?

后端 未结 3 1353
南方客
南方客 2020-12-17 18:23

Ok, I’m trying to understand the reason to use salt.

When a user registers I generate a unique salt for him/her that I store in DB. Then I hash it and the password w

3条回答
  •  情书的邮戳
    2020-12-17 19:22

    Another intention behind the use of a salt is to make sure two users with the same password won't end up having the same hash in the users table (assuming their salt are not the same). However, the combination of a salt and a password may lead to the same "string" or hash in the end and the hash will be exactly the same, so make sure to use a combination of salt and password where two different combination won't lead to the same hash.

提交回复
热议问题