I'm using SHA-512 to hash my passwords (with a salt ofcourse). I don't think that what I want is possible, but let's ask anyway.
Is there a way to check if a string is a SHA-512 (or another algorithm) hash already?
When a user logs in, I want to do a check on his password. If it's still in plain text, it should get converted to a secure form.
Your task is extremely simple and require no strings checking.
Just compare entered password with stored one first.
If matched - here it is, a plain password. So, you can start conversion process.
As @zerkms already mentioned the string length is the most obvious thing you can test against. Also hashes usually are written in hexadecimal, so it only consists of the digits 0 to 9 and the characters a to f. Or as regular expression
/[0-9a-f]{64}/i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With