Why is the PHP crypt() function returning the same thing for two different strings?

后端 未结 3 1950
栀梦
栀梦 2021-01-22 23:49

I\'m using PHP\'s crypt function for password hashing/encryption, but I don\'t think I am doing it right because \"nathan12\" and \"nathan123\" both allow me to log

3条回答
  •  后悔当初
    2021-01-23 00:34

    You should be using password_hash() instead of crypt, for the reasons you mention: "I'm probably not even using the crypt function properly". You say you are getting the salt from the DB... this sounds insecure. with password_hash() you can let PHP handle the salting for you in a secure manner.

    More details on why this is superior: http://www.sitepoint.com/hashing-passwords-php-5-5-password-hashing-api/

提交回复
热议问题