salt helps in two ways:
1) When two (or more) people use the same password, without salt, you can see who uses the same password (hashes anyway). So theoretically, if this person knows one of these passwords, he knows all passwords with the same hash. This is a small reason.
2) The main reason is to prevent attacks, commonly called dictionary attacks or rainbow attacks. In these attacks, someone uses a database of pre-calculated hashes for shared passwords. Often these databases are large in size. But at this point it is very easy to simply look at the hashes that you have (a hashed password) against the list of precomputed hashes and see what is connected with this password.
Using the salt value (as a rule, you want it to be a random number) the hash will not correspond to the dictionary (the probability of their preliminary calculation of all passwords with all possible salt values ​​is exponentially more complicated). Therefore, even if your user uses an easily attacked password, say, “Password”, which is pretty much guaranteed to be in any password / rainbow dictionary, pre-expecting your random salt value, you make the hash pretty much guaranteed to be useless to the attacker. Meanwhile, for you, since the salt is simply stored in the clear, it is very easy for you to add it to your text to compare the password entered by the user.
Zippit
source share