Where is the salt stored for password_hash?

前端 未结 2 1644
醉梦人生
醉梦人生 2021-01-12 09:55

According to (relatively) new PHP documentation:

The password_hash function uses a random salt (which we should not worry about.. O_O), so if I understand correctly

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-12 10:33

    The password_hash manual states

    The used algorithm, cost and salt are returned as part of the hash. Therefore, all information that's needed to verify the hash is included in it. This allows the password_verify() function to verify the hash without needing separate storage for the salt or algorithm information.

    Therefore the salt is already included in the hash you are saving in the db.

提交回复
热议问题