Testing if string is sha1 in PHP

前端 未结 3 1125
渐次进展
渐次进展 2020-12-31 05:33

I\'m planning on storing the passwords as a sha1, so I need a way to validate that it is a sha1 at another point in my website. I was planning on using preg_match, but I do

3条回答
  •  自闭症患者
    2020-12-31 06:20

    When comparing two SHA1 hashes, and you know that the first one is one (because it comes out of the database), then just assume that the second is a SHA1 value as well. You are only interested if two hashes match or not. If one of the compared values is not a possible SHA1 value, then it's particulary not the same as the one in the database. And that's all you need to know.

提交回复
热议问题