Why does PHP crypt() prepend the salt to the hash?

前端 未结 6 1232
终归单人心
终归单人心 2020-12-15 10:02

I am looking into building a login system and after reading the php manual when you pass a 2 digit salt to the crypt() function it returns a hash string, and th

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 10:47

    The salt is appended to the has so that you will know which salt to use when you get the password and want to see if it matches the hash. The idea here is to use a different salt for every password so that someone cannot precompute a hash table.

    You could also append a second salt to every password (the same for all) and not tell anyone what it is.

提交回复
热议问题