I'm using crypt as follows:
$pass = crypt($pass, 'd4');
for both insertion and validation of a password against a mysql table. Problem is that if the passwords are similar it generates a similar result. Is there an algorithm that guarantees different results for different passwords?
Use hash() and choose hashing algorithm that suits you well (if possible something stronger than MD5, but don't go all the way to SHA512 either)
On crypt()'s manual page you will find this:
The standard DES-based crypt() returns the salt as the first two characters of the output. It also only uses the first eight characters of str, so longer strings that start with the same eight characters will generate the same result (when the same salt is used).
which should explain why you get same results.
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