Which PHP function is used to hash passwords securely? a) md5() b) crypt() c)…
- User
Which PHP function is used to hash passwords securely? a) md5() b) crypt() c) password_hash() d) hash()
Assistant
The correct PHP function used to hash passwords securely is c) password_hash().
Here's why:
- a) md5(): MD5 is an outdated and insecure hashing algorithm for passwords. It's very fast, has no built-in salting, and is vulnerable to rainbow table attacks and brute-force attacks.
- b) crypt(): While
crypt()can be used with secure algorithms like Blowfish (which uses by default), it's a lower-level function that requires more manual setup (like generating a salt) and can be more complex to use correctly and securely for passwords. is a more modern and user-friendly wrapper.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.