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

后端 未结 3 1335
南方客
南方客 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条回答
  •  Happy的楠姐
    2020-12-17 19:29

    If an attacker creates a giant table of hash values for plaintext passwords, using a salt prevents him from using the same table to crack more than one password. The attacker would have to generate a separate table for each salt. Note that for this to actually work propertly, your salt should be rather long. Otherwise the attacker's precomputed table is likely to contain the salt+password hash anyway.

提交回复
热议问题