strcmp vs. == vs. === in PHP for checking hash equality

前端 未结 4 1551
暗喜
暗喜 2021-02-19 00:46

I\'m using crypt() to hash passwords in PHP, and am trying to work out the safest way of testing equality of the resulting hash when performing password checks.

4条回答
  •  礼貌的吻别
    2021-02-19 01:13

    I think that using == would be sufficient in your case.

    == checks for equality regardless of type, whereas === checks for equality as well as type.

    1 == "1" = True

    1 === "1" = False

    Since we're not too concerned with type, I'd keep it simple and go with ==.

提交回复
热议问题