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 not know how to make regex patterns. Could someone help me out with one?
Thanks
Edit: I am not trying to see if two hashes match.
Actually, you can use
preg_match()to make sure it’s a 40 characters hexadecimal string as such:To explain the pattern:
If you are trying to make sure that the
sha1()hash matches the password the user provider, you simply rehash like this: